prevent filter excluded files from being deleted

Heiko Schlittermann hs at
Tue Mar 7 12:09:57 UTC 2023

Hello Kevin,

Kevin Korb via rsync <rsync at> (Di 07 Mär 2023 00:01:27 CET):
> I am not 100% sure I am interpreting this correctly but I think you are
> complaining that the file was being deleted in the first command?  If so,
> instead of -F try --include='*/' --exclude='*'.  Otherwise, maybe you want a
> second -F?

For the command line it works, but I'd like to have in a .rsync-filter
on a per directory basis.

> >      a
> >      ├── a-file
> >      └── .rsync-filter
> > 
> >      b
> >      └── a-file

Following your suggestion, I tried:

        # .rsync-filter
        + */
        - *

combined with this command

    rsync --del -F -inav a/ b/
    sending incremental file list
    *deleting   a-file
    .d..t...... ./

Your suggestion (include/exclude on the command line) would work, but as
mentioned, it is not on a per directory basis

    rsync --del --include='*/' --exclude='*' -inav a/ b/
    sending incremental file list
    .d..t...... ./


    rsync --del --filter='- *' -inav a/ b/
    sending incremental file list
    .d..t...... ./

does not remove the excluded files

So, why does rsync remove the files excluded via the .rsync-filter file,
but doesn't touch the files excluded with command line filters?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <>

More information about the rsync mailing list