Both directions Mirror

Martin Pool mbp at samba.org
Thu Oct 25 23:18:25 EST 2001


On 25 Oct 2001, taisaki <zbg63970 at wing.zero.ad.jp> wrote:
> Good evening 

Hello!

> I use d as follows.
> (It is every 5 minutes from Cron)
> 
> #!/bin/sh
> 
> LOCK=/tmp/lock.pid
> 
> if [ ! -e $LOCK ]; then
>      echo 1 > $LOCK
>      rsync -ave ssh --delete /export/mirror user at hostB:/export
>      rsync -ave ssh --delete user at hostB:/export/ /export/mirror/
>      rm > $LOCK

You probably mean to say 

   rm $LOCK

> fi
> 
> However, now, it is.
> It will be deleted even when a file is created on both sides.

I think what this script will do is that files from hostA will
overwrite all files on hostB, and files which do not exist on hostA
will be deleted from hostB.

Normally when people do two-way mirroring, they use the -u (--update)
option, so that files on hostB will only be replaced if they are older
than the file on hostA.  Then, if you run the transfer in the reverse
direction also using -u, files that are newer on hostB will be moved
back.

Unfortunately there is no way to do two-way mirroring including
deletion with rsync unless you can provide it with more information.

Consider the case where a file X exists on hostA but not on hostB.
Should rsync think that the file has been deleted from hostB and it
should therefore be deleted from hostA?  Or should it think that the
file is new on hostA and it should therefore be transferred to hostB.
Without knowing about how the filesystems are used, there is no way to
tell.

> Should the script or something that checks before rsync be put in?
> As operation to desire
> 1 Mirroring of both directions can be performed.
> 2 File deleted by hostA (hostB)  It is deleted also by hostB(hostA).
> 3 File created by hostA   It can update also by hostB.

You seem to say that files are only newly created on hostA, although
they can be deleted or modified on either machine.  Is that really
what you meant?  In this restricted case it may be possible.

--
Martin





More information about the rsync mailing list