rsync 操作在文件级别是原子的吗?

发布于 2024-09-24 14:59:52 字数 355 浏览 9 评论 0原文

我试图弄清楚 rsyncing 文件是否是原子的。我找不到任何关于它的确认。由于 rsync 只能发送增量,我的印象是它也只更新部分实时文件。

另一方面,DJB 建议使用 rsync 来同步实时 .cdb 文件,我找到了这篇文章 ( http://lists.samba.org/archive/rsync/2002-April/002210.html )这两者都意味着新文件已创建,然后移动到正确的位置。

有人可以向我指出确认其中之一的官方消息来源吗?

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 impression that it also updates only parts of the live files.

On the other hang DJB recommends rsync for synchronising live .cdb files and I've found this post ( http://lists.samba.org/archive/rsync/2002-April/002210.html ) which both would imply that the new file is created, then moved over to the proper location.

Can someone point me at an official source confirming one or the other?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

赠我空喜 2024-10-01 14:59:52

Rsync 创建一个新的临时文件,其中包含本地(接收)副本中的块以及发送副本中所需的任何块。完成后,临时文件将被移动到位,替换原始文件。

完整详细信息请参见此处;

http://rsync.samba.org/how-rsync-works.html

Rsync creates a new temporary file which will contain blocks from the local (receiving) copy and whatever blocks it requires from the sending copy. When done the temporary file is moved into place replacing the original.

Full details are here;

http://rsync.samba.org/how-rsync-works.html

旧伤还要旧人安 2024-10-01 14:59:52

rsync 不会自动写入文件。

在传输过程中,会在同一目标目录 (.[original-filename].[6-random-characters]) 中创建一个隐藏的临时文件,其中包含处于当前状态的传输文件。

如果您在传输过程中碰巧失去连接或 rsync 遇到任何其他问题,导致连接关闭,在终止 rsync 进程之前,请执行以下操作:请务必复制临时文件以保留所有已传输的包。您可以简单地重命名临时文件(删除前导“.”和尾随“.xxxxxx”以获得原始文件名)。

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).

云雾 2024-10-01 14:59:52

有一个 perl 脚本应该添加此功能:
http://www.opensource.apple.com /source/rsync/rsync-40/rsync/support/atomic-rsync

问题是我尝试测试它但它不起作用。还有一些东西,因为从 URL 来看,它看起来像是与 rsync 4.0 相关的东西,而 rsync 的当前版本是 2.6.9 !

There is a perl script that is supposed to add this functionality:
http://www.opensource.apple.com/source/rsync/rsync-40/rsync/support/atomic-rsync

The problem is that I tried to test it and it doesn't work. Also there is something strage because from the URL it looks like being something related to rsync 4.0 and the current version of rsync is 2.6.9 !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文