Need help of exclusion options in rsync-3.0.6

Carlos Carvalho carlos at fisica.ufpr.br
Mon Jul 27 08:12:00 MDT 2009


Matt McCutchen (matt at mattmccutchen.net) wrote on 26 July 2009 17:45:
 >On Sun, 2009-07-26 at 21:37 +0530, Jignesh Shah wrote:
 >> I have a situation where I want to delete some of my excluded patterns
 >> but still want to preserve some other. For example consider below
 >> source and destination directory hierarchy.
 >> 
 >>   Source                    Dest
 >>   ----------                   ---------
 >> /foo/bar/                  /foo/bar/
 >>     | -> baz                  | -> baz
 >>     | -> xyz                  | -> xyz
 >>     | -> abc                  | -> abc
 >>                                  | -> old-baz
 >> 
 >> I am below comand using --delete-excluded  and as a result rsync
 >> deletes exluded directories "baz" and "abc" and also deletes
 >> "old-baz". I want to preserve the "old-baz" and "baz" directories on
 >> destination side and want "abc" to gets deleted. Could you tell me how
 >> to tell rsync to do this?
 >> 
 >> rsync -avz /foo/bar/ --delete-excluded --exclude=/baz --exclude=/abc
 >> desthost:/foo/bar/
 >
 >Recall that an exclude filter is shorthand for a hide plus a protect if
 >--delete-excluded is off, or just a hide if it is on..  Since you want
 >some of your filters to protect destination files from deletion but not
 >others, your best bet would be to drop the --delete-excluded and specify
 >individual hide, protect, and plain exclude (hide+protect) filters.  For
 >more detail, carefully read the "FILTER RULES" section of the man page.
 >
 >Something like the following should do what you described:
 >
 >rsync -avz /foo/bar/ --exclude=/baz --filter='H /abc' \
 >	--filter='P /old-baz' desthost:/foo/bar/

Would just --filter='P /abc' (without the --filter='H...') also work?


More information about the rsync mailing list