TuxForLifeからの回答はかなり良いですが、-c
ローカルで同期するときに使用することを強くお勧めします。リモート同期のために時間/ネットワークのペナルティをする価値はないと主張できますが、速度が非常に速いため、ローカルファイルに対しては完全に価値があります。
-c, --checksum
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 con-
nection 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.
これは、同じサイズとタイムスタンプを使用すると失敗する可能性があることを示しています。
セットアップ
$ cd /tmp
$ mkdir -p {A,b}/1/2/{3,4}
$ echo "\___________from A" | \
tee A/1/2/x | tee A/1/2/3/y | tee A/1/2/4/z | \
tr A b | \
tee b/1/2/x | tee b/1/2/3/y | tee b/1/2/4/z | \
tee b/1/2/x0 | tee b/1/2/3/y0 > b/1/2/4/z0
$ find A b -type f | xargs -I% sh -c "echo %; cat %;"
A/1/2/3/y
\___________from A
A/1/2/4/z
\___________from A
A/1/2/x
\___________from A
b/1/2/3/y
\___________from b
b/1/2/3/y0
\___________from b
b/1/2/4/z
\___________from b
b/1/2/4/z0
\___________from b
b/1/2/x
\___________from b
b/1/2/x0
\___________from b
ファイルのサイズとタイムスタンプがすべて同じであるため、何もコピーしないrsync
$ rsync -avu A/ b
building file list ... done
sent 138 bytes received 20 bytes 316.00 bytes/sec
total size is 57 speedup is 0.36
$ find A b -type f | xargs -I% sh -c "echo %; cat %;"
A/1/2/3/y
\___________from A
A/1/2/4/z
\___________from A
A/1/2/x
\___________from A
b/1/2/3/y
\___________from b
b/1/2/3/y0
\___________from b
b/1/2/4/z
\___________from b
b/1/2/4/z0
\___________from b
b/1/2/x
\___________from b
b/1/2/x0
\___________from b
チェックサムを比較するため、正しく機能するrsync
$ rsync -cavu A/ b
building file list ... done
1/2/x
1/2/3/y
1/2/4/z
sent 381 bytes received 86 bytes 934.00 bytes/sec
total size is 57 speedup is 0.12
$ find A b -type f | xargs -I% sh -c "echo %; cat %;"
A/1/2/3/y
\___________from A
A/1/2/4/z
\___________from A
A/1/2/x
\___________from A
b/1/2/3/y
\___________from A
b/1/2/3/y0
\___________from b
b/1/2/4/z
\___________from A
b/1/2/4/z0
\___________from b
b/1/2/x
\___________from A
b/1/2/x0
\___________from b