Hi all, I have been using rsync to copy multiple dirs, eg: rsync -aR dira dirb /tmp Now, I no longer want to copy dirb, and I want it to be removed on the remote side, and I cannot figure how to achieve this. I tried: rsync -aR --exclude=dirb --exclude-deleted dira dirb /tmp but this has no effect. I have searched for similar posts, and found: http://www.mail-archive.com/rsync@lists.samba.org/msg11841.html What is exactly meant by "Rsync only deletes inside directories that it sends" ? I mean, in the command I used, I provide dirb in the list of dirs to be copied, so "send" mean really send over the wire? I have tried what is suggested (ie put dira and dirb into test-rsync/ and send test-rsync): rsync -avn --exclude=dirb --delete-excluded test-rsync/ /tmp but in this particular case, it tries to remove many things in /tmp which is obviously populated with many files ;-) I suppose there is an 'obvious' to do what I want, but how? Thanks, Christophe.
On Fri, Jan 20, 2006 at 03:33:06PM +0100, Christophe LYON wrote:> rsync -avn --exclude=dirb --delete-excluded test-rsync/ /tmp > but in this particular case, it tries to remove many things in /tmp > which is obviously populated with many files ;-)That command tells rsync to make the /tmp dir identical with the sending dir, which is why it tries to remove everything missing from the source dir from the destination dir. There are several solutions, and which one is right for you depends on how new your rsync version is. For instance, a way that works with any rsync version is to copy from an empty dir to get rsync to do a deletion: mkdir empty-directory rsync -av --delete --include=/dirb --exclude='*' empty-directory/ /tmp rmdir empty-directory That tells rsync to only send dirb on the sending side (which is missing) and protects everything except dirb on the receiving side. An alternate way to do this that also updates dira requires at least version 2.6.4: you can use a hide filter to make rsync transfer exactly what you want and avoid deleting anything extra (because you don't need to use --delete-excluded). Like this: rsync -av --del -f 'hide /dirb' --include='/dir[ab]' --exclude='/*' . /tmp This tells rsync to send the parent directory of the dira and dirb dirs with only dira and dirb included in the transfer (you could use separate --include options, if you prefer). It pretends that dirb does not exist on the sending side (due to the hide filter, which must come before the include). On the receiving side, rsync does not protect dirb from deletion because the include rule comes before the exclude rule. The exclude makes sure that nothing else gets deleted in the destination dir. You'll note that all the include/filter/exclude rules are anchored to the root of the transfer so that they only apply where they should (and not accidentally deeper in the transfer). ..wayne..