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
?
rsync -av --exclude=dont_delete_me --delete /sending/path /receiving/path
, wouldn't that makersync
delete everything on the receiving path that does not exist on the sending path, except things matched bydont_delete_me
? Most importantly, wouldrsync
keep things on the receiving side matched bydont_delete_me
even if nothing on the sending side matchesdont_delete_me
? If that's the case, I think that's the only line I need, right? – Amelio Vazquez-Reina Aug 11 '11 at 16:59--delete
, unless you explicitly specify--delete-excluded
. See the description of--delete
and--delete-excluded
in the rsync manual. – Gilles 'SO- stop being evil' Aug 11 '11 at 21:56