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..
-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to