診斷 rsync 為何複製或不複製某些文件

診斷 rsync 為何複製或不複製某些文件

我有一個腳本,用於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,會導致為每個更新或變更的檔案列印一條診斷訊息,以識別對其進行的操作以及原因。指定該選項兩次會導致它還列印根本未更改的文件的訊息。

相關內容