Christophe LYON
2006-Aug-29 17:18 UTC
protecting files from deletion, and using --delete-excluded
Hi all, I am trying to write a script based on rsync to help users select what they want to mirror, what they want to skip and what they want to delete on the remote side. Let's say that I have 1 directory per release: r1.0 r1.1 r2.0 r2.1 r3.1 r3.2 r4.0 r4.1 At some point I have mirrored all of them, but now I want to be able to tell rsync to: - remove all r1.* and r2.* releases - skip r3.* releases (ie don't scan them, but don't delete them) - sync r4.* releases I am trying to use filters: + /r4*/ P /r3*/ + /some-other-dir/ - /* (to remove r1*,r2* but also every thing else I don't want) What I see is that rsync wants to remove all my r3* dirs, while I thought I had protected them. I have read several time the filters documentation but can't figure out what's going on ? Even reading the sources of generator.c didn't help much :-( Thanks, Christophe.
Matt McCutchen
2006-Aug-30 02:11 UTC
protecting files from deletion, and using --delete-excluded
On 8/29/06, Christophe LYON <christophe.lyon@st.com> wrote:> At some point I have mirrored all of them, but now I want to be able to > tell rsync to: > - remove all r1.* and r2.* releases > - skip r3.* releases (ie don't scan them, but don't delete them) > - sync r4.* releases > > I am trying to use filters: > + /r4*/ > P /r3*/ > + /some-other-dir/ > - /* (to remove r1*,r2* but also every thing else I don't want)Protect filters are only relevant for destination files that do not have counterparts on the sender. If you protect /r3*, all the files inside /r3.1 on the receiver will still be deleted if /r3.1 is an empty directory on the sender. To stop the receiver's /r3.1 from being modified at all, you should use both a hide filter (H) and a protect filter (P). On the other hand, if rsync is trying to remove the directory /r3.1 itself, that is a bug, and you should send more information so we can investigate. Matt