rsync --compare-dest、結果が加速されない

rsync --compare-dest、結果が加速されない

rsync --compare-dest期待どおりに動作しようとしましたが、助けが必要です。私の目標は、CentOS用のオフラインストレージデルタを作成することです。 CentOS イメージを保存するサーバーがインターネットに接続されています。オフラインシステムの基準があり、アップデートをディスクに保存する必要があるため、デルタファイルを作成したいと思います。

同じ問題について多くのトピックがあることを知っていますが、動作させることはできません。

以下は、簡単な例を操作しようとした方法の説明です。

[xttomfal@protectera-CentOS-Internet ~]$ ls testdiff1
testfil1  testfil2  testfil3
[xttomfal@protectera-CentOS-Internet ~]$ ls testdiff2
testfil1  testfil2

同じ名前のファイルをコピーするとは、内容がまったく同じであることを意味します。これでdiffresult/testfil3をコピーするディレクトリを作成しました。

ディレクトリを比較すると

[xttomfal@protectera-CentOS-Internet ~]$ diff testdiff1 testdiff2
Only in testdiff1: testfil3
[xttomfal@protectera-CentOS-Internet ~]$

次に、次のようなさまざまなrsync Compare-destコマンドを試しました。

[xttomfal@protectera-CentOS-Internet ~]$ rsync -av --progress --stats --compare-dest=testdiff1 testdiff2/ diffresult/
sending incremental file list
--compare-dest arg does not exist: testdiff1
./
testfil1
              9 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=1/3)
testfil2
              9 100%    8.79kB/s    0:00:00 (xfr#2, to-chk=0/3)

Number of files: 3 (reg: 2, dir: 1)
Number of created files: 2 (reg: 2)
Number of deleted files: 0
Number of regular files transferred: 2
Total file size: 18 bytes
Total transferred file size: 18 bytes
Literal data: 18 bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 215
Total bytes received: 106

sent 215 bytes  received 106 bytes  642.00 bytes/sec
total size is 18  speedup is 0.06
[xttomfal@protectera-CentOS-Internet ~]$ ls diffresult/
testfil1  testfil2
[xttomfal@protectera-CentOS-Internet ~]$

したがって、問題は、コピーされたファイルがDeltaディレクトリのファイルではなく、両方のディレクトリにファイルとして表示されるようです。

ディレクトリ間でdiffファイルのみをコピーする方法はありますか?

ベストアンサー1

ディレクトリ間でdiffファイルのみをコピーする方法はありますか?

はい。あなたの場合、欠けているのは、比較ディレクトリがターゲットに相対的であることです。リンクディレクトリにも同じ問題が適用されます。ここで解決策は絶対パスを使用することです。

想像する

mkdir /tmp/608927
cd /tmp/608927
mkdir testdiff{1,2} changed
touch testdiff1/testfil{1,2,3}
cp -p testdiff1/testfil{1,2} testdiff2/

テストを実行してからファイルをコピーしますtestdiff1が、最新でも最新でもchangedないファイルのみをコピーtestdiff2changed

rsync -av --compare-dest "$PWD"/testdiff2/ testdiff1/ changed/

出力

sending incremental file list
./
testfil3

sent 165 bytes  received 38 bytes  406.00 bytes/sec
total size is 0  speedup is 0.00

証拠

ls changed/
testfil3

ローカルシステムにあるように見えるディレクトリ間でコピーする場合、実質的にコピー全体をrsync作成したりコピーを作成したりしないようにダウングレードされます。ネットワーク接続を介して実行している場合は、rsync各エンドで独自のインスタンスを実行でき、変更のみを転送するという利点があります。

おすすめ記事