I had trouble rsync remote Linux 600 files (rw——-) today. I knew that I came across this issue before but couldn’t remember how I resolved it. Therefore I had to waste time looking for and verifying a solution. Hence this blog post.
This is the problem I had earlier:
rsync -zr userA@remoteServer:/var/www/website/ /home/user/Documents/webSiteBackup/website/www/
rsync: send_files failed to open “/var/www/website/wp-config.php”: Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1655) [generator=3.1.0]
So the issue is that wp-config.php is a 600 file, meaning only root can read and write it. Although userA@remoteServer has sudo privilege, I still need to run visudo so that it won’t ask for password when this user runs rsync.
Here is the line I added into visudo:
userA ALL=(root) NOPASSWD: /usr/bin/rsync
And here is the slightly modified bash command to run:
rsync –rsync-path=”sudo rsync” -zr userA@remoteServer:/var/www/website/ /home/user/Documents/webSiteBackup/website/www/
Hope it helps you as well.