Thank you, it works. But if I want to delete only certain files or dirs from remote side?
example: $ tree dirA/ dirA/ |-- dir2 | `-- file3 |-- file1 `-- file2 $ tree dirB/ dirB/ |-- dir2 | `-- file3 |-- file1 |-- file2 `-- protect1 $ rsync -av --dry-run --delete-excluded -f ". filter" dirA/ dirB/ building file list ... done ./ sent 74 bytes received 26 bytes 200.00 bytes/sec total size is 0 speedup is 0.00 $ cat filter H * P * R dir2* - dir2* I want to delete "dirB/dir2/" only. Not "dirB/protect1" or any other file or dir in "dirB/". What sort of filter I must create? Where can I find example filter files for complicated cases? > On Sun, 2009-10-04 at 00:29 +0400, rs...@xbit.ru wrote: >> I'm trying to create a filter file for rsync what saying which dirs to >> copy. For example i need only /lib and /var/lib dirs from remote >> server. >> I say: >> rsync -f ". /tmp/rsync_dirs" --dry-run --verbose "remote:/" >> "/local_dir/". >> >> File /tmp/rsync_dirs looks like: >> + /lib/ >> + /var/ >> -! /var/lib/* >> - /* >> >> This doesnt work: it copies all /var/ dir except contents of /var/lib/. >> What's wrong? > > Your third rule excludes all files that don't match "/var/lib/*", > and /var/lib is such a file since it has no third path component to > match the "*". Hence the behavior you're seeing. > > Instead, try this approach of including the /var/lib dir and then > excluding everything else at the /var/* level: > > + /lib/ > + /var/ > - /* > + /var/lib/ > - /var/* > > In practice, I have never found a legitimate use for "!" patterns and > believe they are a misfeature. From the version-control history, it > appears that the only use Wayne had in mind for them was to replace the > traditional --include='*/' --exclude='*' (or --filter='S */' > --filter='H *') pattern, but I really don't see what was wrong with that > pattern, as it is consistent with the spirit of all other filter usage I > have seen. Wayne, comments? > > -- > Matt > > > -- 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