Can I get rsync to work under the following conditions?
if len(f1) != len(f2) then rsync
if len(f1) == len(f2) and md5sum(f1) != md5sum(f2) then rsync
The closest is the --checksum
option??
Taken from rsync
manpage:
Description
Rsync is a fast and extraordinarily versatile file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. It offers a large number of options that control every aspect of its behavior and permit very flexible specification of the set of files to be copied. It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination. Rsync is widely used for backups and mirroring and as an improved copy command for everyday use.
Rsync finds files that need to be transferred using a lqquick checkrq algorithm (by default) that looks for files that have changed in size or in last-modified time. Any changes in the other preserved attributes (as requested by options) are made on the destination file directly when the quick check indicates that the file's data does not need to be updated.
So, the default behavior as we can see on the description is:
if len(f1) != len(f2) then rsync
Now, it is just a matter of looking for options related to checksum. Searching at the manuals:
-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 description of --checksum
is exactly what you want on if len(f1) == len(f2) and md5sum(f1) != md5sum(f2) then rsync
. It will do a 128-bit checksum on each size matching file.
But be careful cause this option will, depending on the situation, increase you I/O significantly.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加