当使用 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 -c
或 rsync --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/