Syncing Two Dirs With Rsync

dweimer dweimer at dweimer.net
Thu Jan 10 19:28:11 UTC 2013


On 2013-01-10 12:57, Tim Daneliuk wrote:
> I have used rsync for many years to make sure a destination
> machine:directory is kept up-to-date with some source master
> directory.
>
> I now need to find a way to keep two different machine:dirs
> in sync with each other.  But for any given file, I don't know
> which of these is newer so I don't know "which way" to sync.
>
> For example given:
>
> machineA::/dir/foo      machineB:/dir/foo
> machineA::/dir/bar      machineB:/dir/bar
>
> Say the machineA has the newest foo, but machineB has the
> newest bar.  At the end of syncing, I want both machines
> to have the latest copies of everything.
>
> I'm guessing there's a way to do this with rsync but I'm kind
> of stumped.
>
> Ideas?

Never tried it before, but I would think you could use the -u option to 
skip newer files, and do a push followed by a pull so that the newer 
files from each side get copied.  However you wouldn't be able to use 
the delete files option as new files could get deleted instead of 
copied, depending on which side ran first.

-- 
Thanks,
    Dean E. Weimer
    http://www.dweimer.net/


More information about the freebsd-questions mailing list