<div dir="ltr"><div dir="ltr">On Mon, Nov 2, 2020 at 3:03 AM Manish Jain wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">rsync -av --delete src dst  # but protect dir dst/XYZ from deletion<br>
<br>
I tried "--filter 'protect dst/XYZ'" but that does not prevent the directory dst/XYZ from being deleted.<br></blockquote><div><br></div><div>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).</div><div><br></div><div>*: 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.</div><div><br></div><div>..wayne..</div></div></div>