When syncing my remote backup I get the error rsync cannot delete non-empty directory
.
I know the cause: I have excluded some files and when rsync tries to delete a remote directory because it doesn't exists locally, it can't since it is not empty. Without the exclusion the directory would be emptied.
I also know I could get rid of the problem by using –delete-excluded, but that is not want I want.
I would like to skip uploading certain files (because they are too big for my upload speed), but I want to keep those I have already uploaded some time ago if they exist locally. If they do not exist locally, they should be deleted. –delete-excluded would delete them all on the remote side.
That also means that if a directory doesn't exists anymore locally, it should be deleted even if it contains excluded files.
Is it possible to setup rsync to accomplish this?
Best Answer
Use the
p
modifier:For example, I use the
-F
option, which "tells rsync to look for per-directory .rsync-filter files that have been sprinkled through the hierarchy and use their rules to filter the files in the transfer."My
.rsync-filter
contains lines like these to filter out these "droppings" that Macs leave behind them:If using
exclude
instead of just-
, add a comma. For example :