in reply to
Re^5: Writing to a file atomically without renaming
in thread Writing to a file atomically without renaming
backup_file has different perms because you copied the file to a new file as a different user. I am not saying backup_file is gone if you hit that case -- only that you end up in a situation where your app or the other apps that use that file are looking at corrupt data (they don't know about backup_file).
cat backup_file > file does the following:
# this is where you have the race condition.
redirects the data in backup_file to file.