rsyncは関連ファイルを除外できませんか?

rsyncは関連ファイルを除外できませんか?

rsyncの除外オプションは相対パスのみを許可することがわかっているのでrealpath --relative

$ls /usr/local/bin
cppman  demangle  e  fusuma  rem  triangle
$realpath --relative-to=$PWD /usr/local/bin/cppman
../../usr/local/bin/cppman
$rsync -va --delete --exclude=$(realpath --relative-to=$PWD /usr/local/bin/cppman) /usr/local/bin /home/user1/Desktop/transport/
created directory /home/shepherd/Desktop/transport
bin/
bin/cppman
bin/demangle
bin/e
bin/fusuma
bin/rem
bin/triangle

sent 26,689 bytes  received 189 bytes  53,756.00 bytes/sec
total size is 26,215  speedup is 0.98

ご覧のとおり、ファイルcppmanいいえ相対的であっても除外されます。なぜ?

ベストアンサー1

除外パスは、現在の作業ディレクトリではなくソース(「転送ルート」)に基づいて開始されます。bin転送するディレクトリなので、パスは次のようになります/bin/cppman

rsync -va --delete --exclude=/bin/cppman /usr/local/bin /home/user1/Desktop/transport/

またはアンカーがない場合(引出線なし/):

rsync -va --delete --exclude=bin/cppman /usr/local/bin /home/user1/Desktop/transport/

/usr/local/bin/cppman2つのファイルとがある場合、/usr/local/bin/foo/bin/cppman固定されていないバージョンは両方のファイルを除外し、最初のコマンドは最初のファイルを除外します。

おすすめ記事