running two rsync processes, synchronizing the same directories
matt at mattmccutchen.net
Fri Feb 29 02:49:17 GMT 2008
Please keep this on the list (CC rsync at lists.samba.org).
On Thu, 2008-02-28 at 22:10 +0100, cm wrote:
> > On Wed, 2008-02-27 at 22:29 +0100, cm wrote:
> >> What happens if two rsync process are running, synchronizing the same
> >> directories. In my case it means if two user are launching the rsync command
> >> at the same time to equalize the same files / directories.
> > Nothing terrible, but the two processes might waste time duplicating
> > each other's work. You can avoid the situation using a daemon's "max
> > connections" or your own lock file mechanism.
> What I thought is ... imagine you have two rsync processes starting
> nearly the same time. Using
> the delete option the second rsync process could delete files the first
> has created and vice versa.
The processes might delete each other's temporary files; to stop that,
use --temp-dir or --filter='P .*.??????'. Beyond that, they won't
delete each other's files unless the source directory is modified while
they are running.
> A better example would be:
> process A -> synchronizes directory XX after that directory YY
> nearly the same time (and under the circumstance in the short time
> something has changed on the "sender" side)
> process B -> synchronizes directory YY after that directory XX
> So I expect to have a mixture of synchronized data resulting out of the
> two rsync processes.
True, if the source is modified while rsync is running, you can expect
to get a mixture of old and new data on the destination. But the
problem is the concurrent modification to the source, not the two
processes; it can occur even with a single process.
BTW, the crossover scenario you mentioned won't occur because rsync
processes files in a consistent order: lexicographic binary order on the
file-list path, except that each directory's non-directory children come
before its subdirectories.
More information about the rsync