rsync goodness

Posted on September 11, 2009

So I have been using a simple way to backup my data. I have a NAS (based on awesome freenas) running on my home network. I mount one of its drive in windows and I execute the following code within cygwin:

rsync -avm --exclude="*.obj" --exclude="*.o" --exclude="*.sbr" --exclude="*.pch" --delete --ignore-existing --ignore-errors --force --no-o --no-p --chmod=ugo=rwX /c/Code/ /S/private/Code/

This will backup/sync my Code folder from C drive to S drive (mounted NAS). It works great but unfortunately I have been having lots of rsync warnings as such:

cannot delete non-empty directory xxx

This article suggested it was the use of the “backup flag” -b but I was not using it. It just happened that the issue is actually in the --exclude pattern combined with the --ignore-existing. The excluded files (which happen to have been on my backup drive for some reasons) are not being removed and thus it cannot delete the directories even with the --force option (which is strange).

The solution is to use the flag --delete-excluded:
rsync -avm --exclude="*.obj" --exclude="*.o" --exclude="*.sbr" --exclude="*.pch" --delete --delete-excluded --ignore-existing --ignore-errors --force --no-o --no-p --chmod=ugo=rwX /c/Code/ /S/private/Code/

And voila, no more warnings!

Leave a Reply