I was getting a few odd rsync backup issues that I banged my head against for a good…mmmmmm, 4 hours maybe. It was perplexing only because the errors (to me) were cryptic. I’m posting this because I didn’t seem to find any clear resolution on other sites. I also can’t stand when someone posts an error only to later post an “Oh I figured it out” or “Oh I fixed it” WITHOUT leaving any clue as to HOW they fixed it.
First – lets download a cool chmod utility that shows you in a meaningful visual way how chmod works and what it all means: Classical Web Designs
* That tool was quite helpful in figuring out what chmod number I had by comparing the ‘chmod string’ it also outputs.
RSYNC error: rsync: change_dir#1 failed: Permission denied (13)
* This usually means the directory on your server has the wrong permissions. Note that on FreeNAS the default permissions seem to be 755 or rwxr-xr-x. To fix simply run this command ‘chmod 755 whateverfolder’. You can also run ‘chmod -R 755 whateverfolder’ keep in mind though that I wouldn’t just yet because this will recurs through your folder tree and if it’s only the top level folder having problems you might overwrite sub folder permissions unintentionally.
* Interpreting the error, ‘change_dir’ means that rsync can’t navigate through your remote server directory tree
RSYNC error: rsync: cannot stat destination “/somefolder/somewhere/there”: Input/output error (5)
RSYNC error: rsync: ERROR: cannot stat destination : Permission denied (13)
* This usually means that rsync can’t WRITE to the destination folder so for example, “/somefolder/somewhere/there”. Again this is a permissions issue and you should check the “there” folder permissions and work your way up. Apparently when rsync ‘stats’ your stuff it’s shorthand for writing a temp file in that directory to facilitate the transfer. I don’t pretend to know the nuts and bolts of how it woks but notice this to diagnose the issue.
“destination” – this isn’t your source :p
If you don’t see “rwxr-xr-x” or “youruser:guest” or depending on your system you might see “root:root” you should visit our old buddy chmod again and simply do a: chmod 755 there or chmod 755 /somefolder/somewhere/there. FYI on FreeNAS it’s ‘youruser:guest’, I also recently realized you could do a “chown -r youruser:guest /somefolder/somewhere/there” and that fixes permissions allowing the ownership to go from root:root to the afore mentioned. I think this is preferred to chmod’ing. Also note that you probably want to make a group and put that user into so it’s “customusername:customgroupname”. IF by chance you have users who access the server via ssh, sftp, etc then they won’t be able to navigate to other user folders. I also recently found an interesting article that the author of the article posted on LinkedIn here: firewall.cx. The author does a MARVELOUS job in explaining it. As a result, you might want to setup your groups for your particular users, then do a recursive chown through the directory structure, you will want to then follow that up with a chmod 770. If you do that then another user who tries navigating will get “access denied”…as they should ;)
RSYNC error: rsync: recv_generator: failed to stat “somefolder/somewhere/there”: Input/output error (5)
* This usually means that rsync can’t write to the directory in your SOURCE folder. For example if you use cygwin on a Windows machine and you’re backing up c:\temp ” cygwin ‘/cygdrive/c/temp'” then go into that directory in cygwin and check your permissions.
you might see an owner of ????????? or something that doesn’t look right. In my case the user I was using to run rsync and backup directories didn’t own the directory and couldn’t write files to the root of that directory (I think rsync calls it a ‘manifest’ (list of files to xfer)). So I then looked at the permissions on the Windows side of life and retried the xfer.
What it looked like:
drwx——+ 1 administrator Domain Users 0 Jun 3 2010 Folder1
d———+ 1 ???????? Domain Users 0 May 12 23:11 Folder2
Moral of the story it would seem with RSYNC is that permissions are everything and if you get some type of error it’s usually because rsync can’t hook onto a file or directory with the user you’re running it as. Let me know if this helped you because I spent 4 hours of my life to save you 3 hours and 45 minutes of yours :p
** Update **
I ran into an entirely NEW issue, not sure when this started but when I was reviewing log files on the source server I saw errors:
failed: Permission denied (13)
rsync: recv_generator: failed to stat
My previous methods for troubleshooting this issue didn’t work so…
The FreeNAS forum had a solution for me thanks to poster “danmero”: http://sourceforge.net/apps/phpbb/freenas/viewtopic.php?f=51&t=365
You might need to add the option: “-p –chmod=u=rwx,g=rwx,o=rwx”
This sets permissions on the destination directory and solved my “access denied” issue this round! :)