Need help of exclusion options in rsync-3.0.6

Jignesh Shah jignesh.shah1980 at gmail.com
Mon Jul 27 00:25:53 MDT 2009


Thanks Matt, that was great information.

I think I don't need to use exclude at all and just need to user H and P
flags with --filter option. Also I will need to use --delete option to
remove directories filtered H flag. The below command meets exactly my
requirements:

rsync -avz /foo/bar/  --delete --filter='P /baz' --filter='H
/abc' --filter='P /old-baz' desthost:/foo/bar/

Am I missing anything or anything could be done better way? I hope that
--include option would not get affected with these options.

Thanks a tons,
Jignesh

On Mon, Jul 27, 2009 at 3:15 AM, Matt McCutchen <matt at mattmccutchen.net>wrote:

>  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/
>
> --
> Matt
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/rsync/attachments/20090727/f7deed01/attachment.html>


More information about the rsync mailing list