gentoo@boxhorn-edv.com
2005-Jan-25 17:15 UTC
Sync both sides with deleting from one side and creating files on both sides
Hi folks, i?m not sure if it is even possible, bu just want to ask: I have to servers connected over vpn. On both sides there is a working directory "Office" where the users are working on but deletion should only be possible on side A. The idea is, that on A and B people can work and save over their 100 Mbit Network quite fast, and in the backround the data get synchronized over the slow line. This is all working quite great, but we also want that on side A somebody deletes something, it gets deleted on side B as well. This is working perfect as well. But when side B creates something, it gets deleted on side B, instead of beeing synchrinized. So I have the config: 1 Step: Synchronize everything from A to B and delete everything on B which has been deleted on A. 2. Push all stuff from B to A which has been created on B, and A doesn?t know about. But the Problem is, rsync deletes on step 1 as well all documents, which have been created on side B, because it doesn?t make the difference between: a) it has existed on both sides, and afterwards been deleted on side A, so delete it on side B as well and b) It has never existed on side A, so I would like to have it kept, and at the push, pushed to side A as well Any hints? (Sorry for my english, I?m bavarian) -------------- next part -------------- HTML attachment scrubbed and removed
Wayne Davison
2005-Jan-27 08:45 UTC
Sync both sides with deleting from one side and creating files on both sides
On Tue, Jan 25, 2005 at 06:14:35PM +0100, gentoo@boxhorn-edv.com wrote:> But the Problem is, rsync deletes on step 1 as well all documents, > which have been created on side BExactly, since it is duplicating side A. To do what you want you'll need to either (1) implement your own delete functionality, or (2) add an exclude for every new file on side B. An example of "1" would be to keep a list of the files that were last transferred from A to B (you can glean this from the output of rsync), notice when a file goes missing, and use ssh and a list of files to instruct xargs to remove the vanished files (and, of course, leave off --delete from the rsync command). Something like this might work (untested): rsync -avv somedir host:dest/ | tee xfer-output grep '^somedir/' xfer-output | sed 's/ is uptodate$//' | sort >file-list.new diff file-list.old file-list.new | sed -n 's/^< //p' | ssh host xargs rm -rf mv file-list.new file-list.old Of course, you'd do well to add some error-checking to that for safety (e.g. abort if the rsync command didn't finish successfully). ..wayne..