我将新文件添加到/ dir / a并再次运行相同的命令,它知道它做了什么,并且仅复制新文件。
不,它不知道上一次运行时的操作。它将接收方的数据与要发送的数据进行比较。如果数据足够小,这将不明显,但是当目录足够大时,很容易感觉到在实际开始复制之前进行比较所花费的时间。
默认检查是文件修改时间和大小。来自man rsync
:
-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 "quick check" 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.
和:
-u, --update
This forces rsync to skip any files which exist on the
destination and have a modified time that is newer than the
source file. (If an existing destination file has a
modification time equal to the source file’s, it will be updated
if the sizes are different.)
请注意,您使用的选项并不暗示这些。-a
是:
-a, --archive archive mode; same as -rlptgoD (no -H)
-r, --recursive recurse into directories
-l, --links copy symlinks as symlinks
-p, --perms preserve permissions
-o, --owner preserve owner (super-user only)
-g, --group preserve group
--devices preserve device files (super-user only)
--specials preserve special files
-D same as --devices --specials
-t, --times preserve times
-i
标志非常方便。对于每个文件,它都提供一个匹配字符串,可以对该字符串进行解码,以查看其匹配原因(mod时间标志,大小标志等)