rsync 的-c 和-W 参数的含义到底什么意思?

2019-09-18 10:17:40 +08:00
 kisshere

查了相关释义:

  1. -c:“打开校验开关,强制对文件传输进行校验”。这个校验是指校验什么?文件大小?修改时间? md5 ?如果不增加-c 参数,是不是就一股脑儿直接传过去,存在源文件就覆盖了?
  2. -W:“拷贝文件,不进行增量检测”。这个增量检测到底是什么意思?

求 V 友指教

2185 次点击
所在节点    程序员
2 条回复
wujunchuan2008
2019-09-18 10:56:15 +08:00
-c -- checksum skip based on checksum, not mod-time & size 是基于文件哈希来判断是否覆盖吧
Nimrod
2019-09-18 16:51:10 +08:00
参见 https://linux.die.net/man/1/rsync
-c, --checksum
This changes the way rsync checks if the files have been changed and are in need of a transfer. Without this option, rsync uses a lqquick checkrq that (by default) checks if each file's size and time of last modification match between the sender and receiver. This option changes this to compare a 128-bit checksum for each file that has a matching size. Generating the checksums means that both sides will expend a lot of disk I/O reading all the data in the files in the transfer (and this is prior to any reading that will be done to transfer changed files), so this can slow things down significantly.
The sending side generates its checksums while it is doing the file-system scan that builds the list of the available files. The receiver generates its checksums when it is scanning for changed files, and will checksum any file that has the same size as the corresponding sender's file: files with either a changed size or a changed checksum are selected for transfer.
Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking a whole-file checksum that is generated as the file is transferred, but that automatic after-the-transfer verification has nothing to do with this option's before-the-transfer lqDoes this file need to be updated?rq check.
For protocol 30 and beyond (first supported in 3.0.0), the checksum used is MD5. For older protocols, the checksum used is MD4.
-W, --whole-file
With this option rsync's delta-transfer algorithm is not used and the whole file is sent as-is instead. The transfer may be faster if this option is used when the bandwidth between the source and destination machines is higher than the bandwidth to disk (especially when the lqdiskrq is actually a networked filesystem). This is the default when both the source and destination are specified as local paths.

简而言之,-c 是用 checksum 替代默认 rsync 的增量检测算法,-W 不作增量检测算法,直接拷贝。
增量检测是指针对同一个文件,检查有什么修改。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/601727

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX