[RndTbl] rsync with multi-direction delete.

Adam Thompson athompso at athompso.net
Mon Sep 17 15:17:11 CDT 2007


Montana Quiring wrote:
> What I want: when I delete a file or directory on either place it will
> remove it from the other.
> What it does now: If I delete a directory or file from the server it
> removes it from the USB device (ya!) but if I remove a file/directory
> from the USB device and perform an rsync it replaces the deleted
> file/directory.
>
> Here is the rsync command I'm using:
> rsync --delete --delete-excluded --recursive -uv
> quiringm at 192.168.1.102:/mnt/hdd/music/podcasts/ /Volumes/MEK/Podcasts/
>   
As Bill already suggested, rsync might not be ideal for this situation, 
as it assumes a single-master scenario; you're looking for a 
multi-master architecture.

There is one easy way to use rsync - but you have to know in advance 
which location has the deleted files, and name that as the source.  So 
when sync'ing from server to USB, use the command you mention above, but 
when syncing from USB to server, reverse the last two arguments.  You 
see immediately that you can only make changes to one location OR the 
other in between syncs, as any changes made in one location will always 
be undone by the other.

In fact, true two-way synchronization in the manner you're talking about 
is still a fairly hard problem in the generic case.  It's fairly easy if 
you have some way of keeping a log of all activity to both trees, you 
can compare timestamps to see whose actions need to be replicated where, 
but without any a priori knowledge, how is any tool supposed to know the 
difference between these two scenarios:

    A.  You've added a directory (and some files) to system #1, that 
don't appear on system #2 yet.

    B.  You've deleted a directory (and some files) on system #2, but 
they remain on system #1.

To a sync tool comparing systems #1 and #2, those two scenarios are 
indistinguishable.  And, so far as I know, there's no DWIM extensions to 
rsync yet :-)

One package that *might* be able to solve your problem with some extra 
work on your part is XFile (http://www.idiom.com/~zilla/xfiles.html).

Good luck with this...

-Adam




More information about the Roundtable mailing list