V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
kisshere
V2EX  ›  程序员

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

  •  
  •   kisshere · 2019-09-18 10:17:40 +08:00 · 2275 次点击
    这是一个创建于 1928 天前的主题,其中的信息可能已经有所发展或是发生改变。

    查了相关释义:

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

    求 V 友指教

    wujunchuan2008
        1
    wujunchuan2008  
       2019-09-18 10:56:15 +08:00
    -c -- checksum skip based on checksum, not mod-time & size 是基于文件哈希来判断是否覆盖吧
    Nimrod
        2
    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 不作增量检测算法,直接拷贝。
    增量检测是指针对同一个文件,检查有什么修改。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   945 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 21:24 · PVG 05:24 · LAX 13:24 · JFK 16:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.