Atomic operations in rsync
wayned at samba.org
Sat May 17 17:21:49 GMT 2008
On Thu, May 15, 2008 at 03:47:51PM -0700, shmerl wrote:
> I.e. I use it like this: rsync --delay-updates --remove-source-files $1 $2
> My question is, what happenes first - does the file appear in destination
> (i.e. mv from ~tmp~ to dest), and then removed at the source host, or it is
> first removed and the source and then is moved from ~tmp~ to dest?
What happens is that the receiver first moves the file into its final
spot, and if that succeeds, it sends a success message to the sender,
which then removes the source file.
> Also, is there any way to set up in order in which files will be moved from
> ~tmp~ to dest, if --delay-update is used? What actual order is used by
The only supported order is the alphabetical order of the transfer.
Another way to do an atomic move (which may or may not work for you) is
to do the copy into a different directory (possibly using --link-dest)
and then move the new directory hierarchy into its final place by
renaming an already-created new symlink over the old symlink (don't try
to create a new symlink over the old one, as that is not atomic). That
solves any order issues, as all the files spring into their new state
all at once.
More information about the rsync