rsyncの--fuzzyオプションはどのように機能しますか?

rsyncの--fuzzyオプションはどのように機能しますか?

どのようにrsync --fuzzy動作しますか?期待していた結果は出ません。

マニュアルから:

このオプションは、rsyncに、欠落しているターゲットファイルのデフォルトファイルを見つける必要があることを指示します。現在のアルゴリズムは、ターゲットファイルと同じディレクトリで、サイズと変更時間が同じファイルまたは類似の名前を持つファイルを探します。見つかった場合、rsyncは難読化されたデフォルトファイルを使用して転送速度を上げようとします。

このオプションを繰り返すと、--compare-dest、--copy-dest、または--link-destで指定された一致する代替ターゲットディレクトリでもファジースキャンが完了します。

--deleteオプションを使用すると、潜在的なファジー一致ファイルが削除される可能性があるため、これを回避する必要がある場合は、--delete-afterを使用するか、一部のファイル名を除外するように指定してください。

したがって、次のシェルスクリプトを使用して、rsyncが2回目に実行されたときにtarget / a1ファイルの名前をtarget / a2に変更します。しかし、出力を解釈してみると、このようなことは起こりません(Matched data: 0 bytes)。

#! /usr/bin/env bash
set -e

cd $(mktemp -d)
mkdir source destination
cat /dev/urandom | head --bytes=1M > source/a1
rsync --recursive --times $(pwd)/source/ $(pwd)/destination/
tree
mv source/a1 source/a2
rsync \
    --verbose \
    --recursive \
    --times \
    --delete \
    --delete-after \
    --fuzzy \
    --human-readable \
    --itemize-changes \
    --stats \
    $(pwd)/source/ \
    $(pwd)/destination/
tree
rm -r source destination

出力:

├── destination
│   └── a1
└── source
    └── a1

2 directories, 2 files
building file list ... done
>f+++++++++ a2
*deleting   a1

Number of files: 2 (reg: 1, dir: 1)
Number of created files: 1 (reg: 1)
Number of deleted files: 1 (reg: 1)
Number of regular files transferred: 1
Total file size: 1.05M bytes
Total transferred file size: 1.05M bytes
Literal data: 1.05M 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: 1.05M
Total bytes received: 34

sent 1.05M bytes  received 34 bytes  2.10M bytes/sec
total size is 1.05M  speedup is 1.00
.
├── destination
│   └── a2
└── source
    └── a2

2 directories, 2 files

出力rsync --version

rsync  version 3.1.2  protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

どのようにrsync --fuzzy動作しますか?

なぜ期待した結果が得られないのですか?

ベストアンサー1

rsync2つのローカルファイルツリー間でファイルをコピーするために使用しています。--fuzzyこのモードでは、増分アルゴリズムと関連するすべての最適化(例:)は無視されます。

ローカルファイルをリモートサーバーにコピーして(またはリモートからローカルに、関係ありません)テストを繰り返すことで、期待どおりに機能することを確認できます。

たとえば、スクリプトを2つの場所で変更します$(pwd)/destinationlocalhost:$(pwd)/destinationたとえば、エレガントではありませんが、十分です。

# Set up PKI for localhost
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
ssh localhost id

2番目のスクリプトの結果rsync

building file list ... done
<f+++++++++ a2
*deleting   a1

Number of files: 2 (reg: 1, dir: 1)
Number of created files: 1 (reg: 1)
Number of deleted files: 1 (reg: 1)
Number of regular files transferred: 1
Total file size: 1.05M bytes
Total transferred file size: 1.05M bytes
Literal data: 0 bytes
Matched data: 1.05M bytes
File list size: 0
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 4.20K
Total bytes received: 6.18K

sent 4.20K bytes  received 6.18K bytes  20.75K bytes/sec
total size is 1.05M  speedup is 101.09

おすすめ記事