別のディレクトリに再同期する方法は?

別のディレクトリに再同期する方法は?

これが私が達成したいものです:

Rsyncを実行して、次のように2つのディレクトリを再帰的に比較します。

rsync -r /source /target

ただし、実際にはディレクトリ間の再同期ではありません。 3.結果の違いrsyncd /を別のディレクトリにコピーしたいと思います。

どんなアイデアがありますか?

ベストアンサー1

--compare-destあなたの友達はここにいますか:

rsync -rvn --compare-dest /target/ /source/ /extra_target/

(-vと-nが適用されていることを確認してから削除)

これを示すシェルセッションは次のとおりです。

dennis@lightning:~$ cd /tmp
dennis@lightning:/tmp$ mkdir rs1
dennis@lightning:/tmp$ touch rs1/f1
dennis@lightning:/tmp$ rsync -av rs1/ rs2/
sending incremental file list
created directory rs2
./
f1

sent 96 bytes  received 34 bytes  260.00 bytes/sec
total size is 0  speedup is 0.00
dennis@lightning:/tmp$ touch rs1/f2
dennis@lightning:/tmp$ rsync -avn rs1/ rs2/
sending incremental file list
./
f2

sent 71 bytes  received 18 bytes  178.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
dennis@lightning:/tmp$ rsync -avn rs1/ rs3/
sending incremental file list
created directory rs3
./
f1
f2

sent 49 bytes  received 15 bytes  128.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
dennis@lightning:/tmp$ rsync -rnv --compare-dest /tmp/rs2/ rs1/ rs3/
sending incremental file list
created directory rs3
f2

sent 49 bytes  received 15 bytes  128.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)

おすすめ記事