I have read these threads:
- rsync --delete --files-from=list / dest/ does not delete unwanted files
- Delete extraneous files from dest dir via rsync?
But, as far as I can tell (maybe I am missing something), they don't cover the following question:
How do you ask rsync
to copy files and delete those on the receiving side that do not exist on the sending side, with exceptions? (e.g. don't remove a mercurial repository .hg
on the receiving side, even if there is no repository on the sending side).
One possibility?
Borrowing from @Richard Holloway's answer below. Say I have the following line:
rsync -av --exclude=dont_delete_me --delete /sending/path /receiving/path
As far as I understand, this line would make rsync
delete everything on the receiving path that does not exist on the sending path, except those things matched by dont_delete_me
. My question now is: Would rsync keep files on the receiving side that are matched by dont_delete_me
even if nothing on the sending side matches dont_delete_me
?