dat*_*ess 37
如果您通过 rsync 两个本地路径,它将默认使用“--whole-file”,而不是增量传输。所以,你要找的是“--no-whole-file”。如果您要求'-c',您还可以获得增量传输。
以下是您可以验证的方法:
$ mkdir a b
$ dd if=/dev/zero of=a/1 bs=1k count=64
$ dd if=/dev/zero of=a/2 bs=1k count=64
$ dd if=/dev/zero of=a/3 bs=1k count=64
$ rsync -av a/ b/
sending incremental file list
./
1
2
3
sent 196831 bytes received 72 bytes 393806.00 bytes/sec
total size is 196608 speedup is 1.00
Run Code Online (Sandbox Code Playgroud)
然后触摸一个文件并重新同步
$ touch a/1
$ rsync -av --inplace a/ b/
sending incremental file list
1
sent 65662 bytes received 31 bytes 131386.00 bytes/sec
total size is 196608 speedup is 2.99
Run Code Online (Sandbox Code Playgroud)
您可以使用“ls -li”验证它是否重新使用了 inode,但请注意它发送了整个 64K 字节。再试一次 --no-whole-file
$ touch a/1
$ rsync -av --inplace --no-whole-file a/ b/
sending incremental file list
1
sent 494 bytes received 595 bytes 2178.00 bytes/sec
total size is 196608 speedup is 180.54
Run Code Online (Sandbox Code Playgroud)
现在您只发送了 494 个字节。您可以使用 strace 进一步验证是否写入了任何文件,但这表明它至少使用了增量传输。
请注意(请参阅注释),对于本地文件系统,--whole-file
假定为(请参阅 rsync 的手册页)。另一方面,--no-whole-file
假设跨网络,因此--inplace
其自身将表现为--inplace --no-whole-file
。
小智 16
这是我猜的明确答案,引用了手册的正确部分:
--inplace
[...]
This option is useful for transferring large files
with block-based changes or appended data, and
also on systems that are disk bound, not network
bound. It can also help keep a copy-on-write
*************
filesystem snapshot from diverging the entire con?
*******************
tents of a file that only has minor changes.
Run Code Online (Sandbox Code Playgroud)
小智 5
rsync 的增量传输算法处理是传输整个文件还是仅传输不同的部分。这是在两台机器之间同步文件以节省带宽时的默认行为。这可以用--whole-file
(或-W
)覆盖以强制rsync
传输整个文件。
--inplace
处理rsync
在传输过程中是否会创建一个临时文件。默认行为是创建一个临时文件。这提供了一种安全措施,因为如果传输中断,目标机器中的现有文件保持完整/不变。--inplace
覆盖此行为并告诉rsync
直接更新现有文件。这样,如果传输中断,您将面临目标计算机中文件不一致的风险。
小智 3
从手册页:
This option changes how rsync transfers a file when its data
needs to be updated: instead of the default method of creating a
new copy of the file and moving it into place when it is com-
plete, rsync instead writes the updated data directly to the
destination file.
Run Code Online (Sandbox Code Playgroud)
这让我相信它会完整地写入文件——我想 rsync 几乎不可能以任何其他方式工作。
归档时间: |
|
查看次数: |
51415 次 |
最近记录: |