rsync in-place (was Re: rsync 1tb+ each day)

jw schultz jw at
Thu Feb 6 06:13:25 EST 2003

On Wed, Feb 05, 2003 at 10:52:45AM -0800, Ben Escoto wrote:
> On Wed, Feb 05, 2003 at 09:17:03AM -0800, Mike Rubel wrote:
> > >   CB> Of course, a major issue with --inplace is that the file will be
> > >   CB> in an intermediate state if rsync is killed mid-transfer.  Rsync
> > >   CB> currently ensures that every file is either the original or new.
> > > 
> > > I'm curious, how does it ensure this?
> > 
> > During the copy, rsync writes to a temporary file in the same directory
> > (the temp file is hidden; it starts with a ".").  Then, once the transfer
> > is done, it mv's that temp file over the original.  My understanding is
> > that mv is atomic under unix, so this action either happens in its
> > entirety or not at all.
> Even if mv is atomic, how does rsync make sure that the move doesn't
> happen before the last of the data is written to the tempfile?  Does
> it explicity fsync the tempfile, or is there some other way it knows?

Rsync doesn't fsync nor open the files O_SYNC so IF your
system crashed before flushing it is possible that the file
could be in a corrupted state on reboot.  If your system
crashes in the middle of an rsync you probably would want to
rerun the rsync anyway.  After all unless you are only
syncing one file you probably would have an inconsistant
tree (some files up-to-date, some not).

Adding fsync or O_SYNC would not exactly help performance
much either.

	J.W. Schultz            Pegasystems Technologies
	email address:		jw at

		Remember Cernan and Schmitt

More information about the rsync mailing list