Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3
On 24/03/10 12:15, PƔdraig Brady wrote:
> Also I noticed that `mv -b ./file.tmp ./file` is not atomic
> because the renames are done like: rename(file,bak); rename(tmp,file);
I summarized the issues involved with replacing files and it was surprisingly
popular:
http://www.reddit.com/r/programming/comments/bhnab/replacing_a_file_on_unix_is_hard/
It was indirectly suggested there to use hardlinks for atomic backups,
which I've amended the attached script to do. Other changes include
falling back to cp -a if --attributes-only is not supported, and
correctly removing all temp files.
I wonder should `mv -b` (and sed -i) use the ln method to
try to be atomic and then fall back to the double rename?
I'll look into it at some stage.
cheers,
PƔdraig.