A strange problem with my daily backups performed via rsync

Wayne Davison wayne at opencoder.net
Mon Nov 2 21:52:07 UTC 2020


On Mon, Nov 2, 2020 at 3:03 AM Manish Jain wrote:

> rsync -av --delete src dst  # but protect dir dst/XYZ from deletion
>
> I tried "--filter 'protect dst/XYZ'" but that does not prevent the
> directory dst/XYZ from being deleted.
>

The "dst" dir isn't in the transfer, so it can't appear in a filter rule*.
If you really specified "src" instead of "src/" (with a trailing slash)
there's no way rsync would ever delete dst/XYZ since it's putting all files
into dst/src. You could protect dst/src/XYZ using a filter of "protect
/src/XYZ/" (the leading slash makes it match at the top of the transer, and
the trailing slash makes it match only a dir).  If you're actually copying
"src/" then you would "protect /XYZ/" (you should always match the names
you see in the transfer's verbose output).

*: Note that you could alternately specify an absolute filter rule such as
--filter "P/ /mnt/dst/XYZ/" since the "/" qualifier to the protect makes it
match an absolute  pathname.  Those rules are slightly less efficient than
matching transfer paths since rsync has to convert the name before it can
compare it, but that tends to not be a big deal for most transfers.

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


More information about the rsync mailing list