prevent filter excluded files from being deleted

Robin Lee Powell robinleepowell at
Tue Mar 7 15:20:39 UTC 2023

On Tue, Mar 07, 2023 at 01:16:07PM +0100, Heiko Schlittermann via rsync wrote:
> Robin Lee Powell via rsync <rsync at> (Di 07 Mär 2023 07:07:01 CET):
> > Read the "PER-DIRECTORY RULES AND DELETE" of the man page.  (And
> > don't feel bad, it took me a while to figure it out myself).
> I did, but left with some uncertainty.
> "H" hides the files from the transfer? What does it mean?
> "P" protects files from being deleted? 
> I even tried '+r *', no luck.
> > Short version: per-directory rules only apply on the side they're
> > *specified on*, but you need the exclusion to apply to *both* sides.
> Hm. Maybe more reasoning behind.
> I'm syncing a quite large tree, but some directories contain huuge VM images,
> which I need to transfer using another mechanism. Because rsync doesn't
> seem to handle filesizes of about 100…500GiB well.
> These directories should contain a `.rsync-filter` to prevent them from
> the sync, but rsync should not remove these same-named files on the
> remote side.

First of all, I disagree that rsync handles very large files badly,
but that's not super relevant. :)  Consdier --partial for large


Note that:

(1) my .rsync-filter file has "+ .rsync-filter" in it
(2) --delete-after means that the .rsync-filter is present on *both
sides* when the delete runs

Exclusion on the *sender* side means "don't send this"; exclusion on
the *receiver* side means "don't delete this".

*Normally*, they're the same, like if you do --exclude=foo in the
command, that affects *both* the sender and receeiver side, but with
-F, the sender side uses the .rsync-filter in its directory, and the
receiver side uses the .rsync-filter in *its* directory.

So if you want the files to be excluded from sending *and* deleting,
the .rsync-filter that excludes the files has to be present on
*both* sides.

You can do that by just manually making them in both places, or by
copying what I had in my email.

> -- 
> Please use reply-all for most replies to avoid omitting the mailing list.
> To unsubscribe or change options:
> Before posting, read:

More information about the rsync mailing list