rsync mirroring and hardlink issues

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


Wayne,

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?

Matt

On 4/26/07, Matt McCutchen <hashproduct+rsync at gmail.com> 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