filtered --delete ?

Matt McCutchen matt at
Mon Jun 23 23:55:59 GMT 2008

On Mon, 2008-06-23 at 15:05 +0000, Corey wrote:
> Is there any way of filtering which files --delete removes?
> ...something like a --delete-exclude=FILTER option or something equivalent?

This is exactly what "protect" filters (--filter='P pattern') do.

Actually, by default, a plain exclude like --exclude=pattern or
--filter='- pattern' both "hides" matching source files from the file
list and "protects" matching destination files from deletion.  With
--delete-excluded, plain excludes only hide and you have to use
--filter='P pattern' to protect.

> I want to do an rsync on multiple directories, however I only want one of
> these directories to have files deleted, or I only want certain specific
> files deleted, not all of them - is this possible?

Do something like --filter='R /delete/in/D/*' --filter='P *'.  The "R"
is for "risk", the opposite of "protect".  Files in directory D will
match the first filter and be considered for deletion, while all other
files will match the second and be protected from deletion.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url :

More information about the rsync mailing list