Are rsync operations atomic at file level?

前端 未结 3 1216
粉色の甜心
粉色の甜心 2020-12-20 11:38

I\'m trying to figure out how if rsyncing files is atomic. I couldn\'t find any confirmation about it. Due to rsync being able to send only deltas, I was under the impressio

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-20 12:15

    No, rsync does not write files atomically.

    During transfer, a hidden temporary file is being created within the same target directory (.[original-filename].[6-random-characters]) which contains the transferred file in its current state.

    If you should happen to lose connection during transfer or rsync encounters any other problem, causing the connection to be closed, before killing the rsync process make sure to copy the temporary file in order to keep all the already transferred packages. You can simply rename the temp file (remove the leading "." and the trailing ".xxxxxx" to get the original filename).

提交回复
热议问题