Good evening 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@hostB:/export rsync -ave ssh --delete user@hostB:/export/ /export/mirror/ rm > $LOCK fi However, now, it is. It will be deleted even when a file is created on both sides. 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. I want to use mirroring of both directions. Is there any good method?
On 25 Oct 2001, taisaki <zbg63970@wing.zero.ad.jp> wrote:> Good eveningHello!> 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@hostB:/export > rsync -ave ssh --delete user@hostB:/export/ /export/mirror/ > rm > $LOCKYou 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
point-by-point>As operation to desire >1 Mirroring of both directions can be performed.If you mirror both directions, which change takes precedence? example: Host a, modifies /foo/bar. Host b does as well. you mirror both ways, now, which version do we have?>2 File deleted by hostA (hostB) It is deleted also by hostB(hostA).This is unclear. if you mean deleting the file on hostA, then rsyncing to hostB will delete the file on hostB, you're right. if you mean deleting the file on hostB gets it deleted from hostA, how do we know which to do? copy the file from A to B, or delete it from A? (see #1 above)>3 File created by hostA It can update also by hostB.see #1 above, again. There's a product called Unison. I don't use it, and can't help you set it up, but it actually does somehow try to keep this sort of stuff straight. It must keep a database of the contents of both filesystems, in order to resolve conflicts. It actually sounds like your need is for a distributed filesystem, though... maybe coda (no useful knowledge about that one, either. I know dce/dfs, but that's not free, and not widely available)? Tim Conway tim.conway@philips.com 303.682.4917 Philips Semiconductor - Longmont TC 1880 Industrial Circle, Suite D Longmont, CO 80501 Available via SameTime Connect within Philips, n9hmg on AIM perl -e 'print pack(nnnnnnnnnnnn, 19061,29556,8289,28271,29800,25970,8304,25970,27680,26721,25451,25970), ".\n" ' "There are some who call me.... Tim?"