我有一个脚本,用于rsync
从远程服务器获取文件,然后处理它们。这些本地副本在运行之间不会被删除,因此rsync
只需获取新的文件。但是,似乎rsync
每次都会下载每个文件,即使缓存的本地副本和服务器副本都没有改变,我也知道为什么。
是否有一些命令行参数rsync
可以帮助我诊断为什么在本次运行中复制或不复制给定文件?我试过了-v
,但它似乎没有给我所需的信息。类似的东西:
> rsync --diagnose-why-files-copied remotehost:/remote/path ./local/path/
'remotehost:/remote/path/file1':
Destination file './local/path/file1' does not exist; copying.
'remotehost:/remote/path/file2':
Destination file './local/path/file2' exists...
Destination file size does not match source file size; copying.
'remotehost:/remote/path/file3':
Destination file './local/path/file3' exists...
File sizes match...
Destination file modification date does not match source file modification date; copying.
'remotehost:/remote/path/file4':
Destination file './local/path/file4' exists...
File sizes match...
File modification dates match...
No change detected; skipping.
> rsync -c --diagnose-why-files-copied remotehost:/remote/path2 ./local/path2/
'remotehost:/remote/path2/file1':
Destination file './local/path2/file1' does not exist; copying.
'remotehost:/remote/path2/file2':
Destination file './local/path2/file2' exists...
Destination file checksum does not match source file checksum; copying.
'remotehost:/remote/path2/file3':
Destination file './local/path2/file3' exists...
File checksums match...
No change detected; skipping.
答案1
-ii
正是我想要的。该--itemize-changes
选项的缩写形式-i
会打印出每个更新或更改的文件的诊断消息,指明对该文件做了什么以及为什么这样做。指定该选项两次还会打印未更改的文件的消息。