<div>Thanks Matt, that was great information.</div>
<div> </div>
<div>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:</div>
<div> </div>
<div>rsync -avz /foo/bar/ --delete --filter='P /baz' --filter='H /abc' --filter='P /old-baz' desthost:/foo/bar/</div>
<div> </div>
<div>Am I missing anything or anything could be done better way? I hope that --include option would not get affected with these options.<br><br>Thanks a tons,</div>
<div>Jignesh</div>
<div> </div>
<div class="gmail_quote">On Mon, Jul 27, 2009 at 3:15 AM, Matt McCutchen <span dir="ltr"><<a href="mailto:matt@mattmccutchen.net">matt@mattmccutchen.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="h5">On Sun, 2009-07-26 at 21:37 +0530, Jignesh Shah wrote:<br>> I have a situation where I want to delete some of my excluded patterns<br>> but still want to preserve some other. For example consider below<br>
> source and destination directory hierarchy.<br>><br>> Source Dest<br>> ---------- ---------<br>> /foo/bar/ /foo/bar/<br>> | -> baz | -> baz<br>
> | -> xyz | -> xyz<br>> | -> abc | -> abc<br>> | -> old-baz<br>><br>> I am below comand using --delete-excluded and as a result rsync<br>
> deletes exluded directories "baz" and "abc" and also deletes<br>> "old-baz". I want to preserve the "old-baz" and "baz" directories on<br>> destination side and want "abc" to gets deleted. Could you tell me how<br>
> to tell rsync to do this?<br>><br>> rsync -avz /foo/bar/ --delete-excluded --exclude=/baz --exclude=/abc<br>> desthost:/foo/bar/<br><br></div></div>Recall that an exclude filter is shorthand for a hide plus a protect if<br>
--delete-excluded is off, or just a hide if it is on.. Since you want<br>some of your filters to protect destination files from deletion but not<br>others, your best bet would be to drop the --delete-excluded and specify<br>
individual hide, protect, and plain exclude (hide+protect) filters. For<br>more detail, carefully read the "FILTER RULES" section of the man page.<br><br>Something like the following should do what you described:<br>
<br>rsync -avz /foo/bar/ --exclude=/baz --filter='H /abc' \<br> --filter='P /old-baz' desthost:/foo/bar/<br><br>--<br><font color="#888888">Matt<br><br></font></blockquote></div><br>