rsync mirroring and hardlink issues

Matt McCutchen hashproduct+rsync at
Fri Apr 27 00:24:31 GMT 2007


It would be nice if support/atomic-rsync supported the technique below
(which is actually atomic) in addition to or instead of the current
technique.  Shall I implement this?


On 4/26/07, Matt McCutchen <hashproduct+rsync at> wrote:
> If you're concerned about concurrent access to the repository while
> the mirroring is in progress, you can use a symlink to do an atomic
> cutover:
> # one-time setup (not safe for concurrent access)
> mv rep_a rep_a.0
> ln -s rep_a.0 rep_a
> # sync
> oldr=$(readlink rep_a)
> newr=${oldr%.*}.$((1-${oldr##*.}))
> rsync -a --link-dest=../$oldr/ src/ $newr/
> ln -s $newr rep_a.tmp
> mv -T rep_a.tmp rep_a
> rm -r $oldr
> This is a slight improvement of the technique used by the script
> "support/atomic-rsync" in the rsync source tree.

More information about the rsync mailing list