<div>Thanks Matt, that was great information.</div>
<div> </div>
<div>I think I don&#39;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=&#39;P /baz&#39; --filter=&#39;H /abc&#39; --filter=&#39;P /old-baz&#39; 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">&lt;<a href="mailto:matt@mattmccutchen.net">matt@mattmccutchen.net</a>&gt;</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>&gt; I have a situation where I want to delete some of my excluded patterns<br>&gt; but still want to preserve some other. For example consider below<br>
&gt; source and destination directory hierarchy.<br>&gt;<br>&gt;   Source                    Dest<br>&gt;   ----------                   ---------<br>&gt; /foo/bar/                  /foo/bar/<br>&gt;     | -&gt; baz                  | -&gt; baz<br>
&gt;     | -&gt; xyz                  | -&gt; xyz<br>&gt;     | -&gt; abc                  | -&gt; abc<br>&gt;                                  | -&gt; old-baz<br>&gt;<br>&gt; I am below comand using --delete-excluded  and as a result rsync<br>
&gt; deletes exluded directories &quot;baz&quot; and &quot;abc&quot; and also deletes<br>&gt; &quot;old-baz&quot;. I want to preserve the &quot;old-baz&quot; and &quot;baz&quot; directories on<br>&gt; destination side and want &quot;abc&quot; to gets deleted. Could you tell me how<br>
&gt; to tell rsync to do this?<br>&gt;<br>&gt; rsync -avz /foo/bar/ --delete-excluded --exclude=/baz --exclude=/abc<br>&gt; 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 &quot;FILTER RULES&quot; 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=&#39;H /abc&#39; \<br>       --filter=&#39;P /old-baz&#39; desthost:/foo/bar/<br><br>--<br><font color="#888888">Matt<br><br></font></blockquote></div><br>