linux - rsync 如何对 rsync 进行校验和

标签 linux bash rsync checksum

当使用 rsync 时,有时 rsync 不会复制所有完成的文件,下面是我使用的代码。它们是一种在 rsync 之后执行校验和或检查以查看是否所有文件都已被复制,如果没有再试直到所有文件都被复制的方法吗?

TEMP="/home/user/temp"
OPTS="-rav -h"

rsync $OPTS --stats user@example.com:/home/user/Local $TEMP

最佳答案

正如 uʍop ǝpısdn 的回答所暗示的,rsync -crsync --checksum 可能会满足您的需要。

-c, --checksum: skip based on checksum, not mod-time & size

This forces the sender to checksum every regular file using a 128-bit MD4 checksum. It does this during the initial file-system scan as it builds the list of all available files. The receiver then checksums its version of each file (if it exists and it has the same size as its sender-side counterpart) in order to decide which files need to be updated: files with either a changed size or a changed checksum are selected for transfer. Since this whole-file checksumming of all files on both sides of the connection occurs in addition to the automatic checksum verifications that occur during a file's transfer, this option can be quite slow.

Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking its whole-file checksum, but that automatic after-the-transfer verification has nothing to do with this option's before-the-transfer "Does this file need to be updated?" check.

如今,对这种速度缓慢的担忧可能已不复存在,当您不能或不想依赖修改时间时,这似乎是一个不错的选择。

关于linux - rsync 如何对 rsync 进行校验和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15787676/

相关文章:

linux - 命令显示正确,但随后执行不同

android - 使用 Android NDK 编译 libpcap

linux - 覆盖linux中正在运行的进程的函数

bash - bash 中嵌套命令的 Heredoc

objective-c - 更改 MAC 地址 Cocoa - Objective-C

bash - 脚本 shell 如何将 x 分钟添加到给定日期?

linux - rsync如何包含目录但不包含文件?

linux - 比较 valgrind、massif、top 和 pmap

Python rsync脚本目录名镜像

linux - 如何从 rsync 中排除两台服务器上都存在的目录?