filtered --delete ? - Tools

This is a discussion on filtered --delete ? - Tools ; Is there any way of filtering which files --delete removes?
....something like a --delete-exclude=FILTER option or something equivalent?
I want to do an rsync on multiple directories, however I only want one of
these directories to have files deleted, or ...

Ah - nice, I had overlooked that while perusing the man page; too much
in a hurry for my own good!

> 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.
>

Re: filtered --delete ?

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.