Syncing from two sources to one target and deleting files not in either source

Wayne Davison wayne at opencoder.net
Tue Jul 21 19:26:26 UTC 2020


On Tue, Jul 21, 2020 at 4:15 AM @lbutlr wrote:

> how can I remove files on Server 3 that do not exist on either Server 1 or
> Server 2?
>

If you want rsync to do the deletions during a copy from one of the
servers, you'll need a filter file of "protect" (P) rules for every dir and
file on the other source server (you could also cull the list to avoid P
rules for files that they have in common, but that's not mandatory).  The
filter file would need to have lines like "P /foo" and "P /path/bar" in it
where the "/" refers to the top of the transfer, not the top of the
filesystem. That would allow you to copy from (for instance) server 1 with
--filter=". protect-rules" and --del (and --dry-run the first time) and
have it avoid removing any of the files unique to server 2.

..wayne..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/rsync/attachments/20200721/edd33af2/attachment.htm>


More information about the rsync mailing list