prevent filter excluded files from being deleted
Robin Lee Powell
robinleepowell at gmail.com
Tue Mar 7 06:07:01 UTC 2023
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).
Short version: per-directory rules only apply on the side they're
*specified on*, but you need the exclusion to apply to *both* sides.
The following works, for the reasons specified there:
rlpowell at stodi> find a b -ls
703572129 0 drwxr-xr-x 2 rlpowell rlpowell 39 Mar 6 22:06 a
704372871 0 -rw-r--r-- 1 rlpowell rlpowell 0 Mar 6 21:56 a/file
704372873 4 -rw-r--r-- 1 rlpowell rlpowell 20 Mar 6 22:06 a/.rsync-filter
703572158 0 drwxr-xr-x 2 rlpowell rlpowell 39 Mar 6 22:06 b
704372870 0 -rw-r--r-- 1 rlpowell rlpowell 0 Mar 6 22:06 b/file
704372881 4 -rw-r--r-- 1 rlpowell rlpowell 20 Mar 6 22:06 b/.rsync-filter
rlpowell at stodi> cat a/.rsync-filter
+ .rsync-filter
- *
rlpowell at stodi> rsync -F --delete-after -iav a/ b/
building file list ... done
sent 102 bytes received 11 bytes 226.00 bytes/sec
total size is 20 speedup is 0.18
rlpowell at stodi>
On Mon, Mar 06, 2023 at 10:04:52PM +0100, Heiko Schlittermann via rsync wrote:
> Hello,
>
> given are 2 directories:
>
> a
> ├── a-file
> └── .rsync-filter
>
> b
> └── a-file
>
> I'd like to sync a/ -> b/, but I'd like to *exclude* all files. But I do
> not want to delete the excluded files. (The real scenario is a way more
> complex, the above is my reproducer.)
>
> and the following rsync command: `rsync -F --del a/ b/`
> Note, there is *no* `--delete-excluded`:
>
> $ rsync -F --del -inav a/ b/
> sending incremental file list
> *deleting a-file
> .d..t...... ./
>
> sent 62 bytes received 29 bytes 182.00 bytes/sec
> total size is 0 speedup is 0.00 (DRY RUN)
>
> Why? Because it is excluded? Using the `--exclude` option does what I
> expect:
>
> $ rsync --exclude 'a-file' --del -inav a/ b/
> sending incremental file list
> .d..t...... ./
> >f+++++++++ .rsync-filter
>
> sent 92 bytes received 22 bytes 228.00 bytes/sec
> total size is 4 speedup is 0.04 (DRY RUN)
>
> even does what I expect:
>
> $ rsync --filter '- *' --del -inav a/ b/
> sending incremental file list
> .d..t...... ./
>
> sent 58 bytes received 19 bytes 154.00 bytes/sec
> total size is 0 speedup is 0.00 (DRY RUN)
>
> Version:
> rsync version 3.2.3 protocol version 31
>
> Best regards from Dresden/Germany
> Viele Grüße aus Dresden
> Heiko Schlittermann
> --
> SCHLITTERMANN.de ---------------------------- internet & unix support -
> Heiko Schlittermann, Dipl.-Ing. (TU) - {fon,fax}: +49.351.802998{1,3} -
> gnupg encrypted messages are welcome --------------- key ID: F69376CE -
> --
> Please use reply-all for most replies to avoid omitting the mailing list.
> To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
> Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
More information about the rsync
mailing list