Hi, first I got to say, thank you to the people who invested certainly much time to build this tool !! Nevertheless I need some information, which I couldn't find in the documentation. At the moment I have to build a web based synchronisation backend. In this case a user can initiate a rsync process to synchronize directories. Question1: 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. Question2: How can I benefit from the -n Option (--dry-run) ? Am I right, when I say before you do a real rsync you can check it with "-n". Does that mean, if a rsync with "-n" does function, the real rsync (without -n) should also work ? Thanks for taking time to answer. Best Regards Christoph
Matt McCutchen
2008-Feb-27 22:25 UTC
running two rsync processes, synchronizing the same directories
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. See: http://www.mail-archive.com/rsync@lists.samba.org/msg20748.html> How can I benefit from the -n Option (--dry-run) ? Am I right, when I say > before you do a real rsync you can check it with "-n". Does that mean, if > a rsync with "-n" does function, the real rsync (without -n) should also > work ?It depends on what you mean. If the dry run prints out the correct set of actions to be performed on the destination, you know that the real run will attempt to perform exactly those actions. However, the actions could fail in ways that rsync would not anticipate on a dry run, e.g., due to restrictive destination file permissions or lack of disk space. Matt
Matt McCutchen
2008-Feb-29 02:49 UTC
running two rsync processes, synchronizing the same directories
Christoph, Please keep this on the list (CC rsync@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. Matt