rsyncを除く*2021*は機能しますが*2020*は機能しません

rsyncを除く*2021*は機能しますが*2020*は機能しません

スマートフォンで写真をバックアップするために長年使用されてきたrsyncコマンドがあります。--exclude *2021*切り替えない限り正常に動作します。--exclude *2020*

私の実際のシナリオでは、エラーメッセージは次のとおりです。

予期しないローカル引数: /media/sciuro/BCKP_WD4T/Fotos/2021/CELULAR/ 引数がリモートファイル/ディレクトリの場合は、前にコロン(:)を付けます。 rsyncエラー:main.c(1375)の構文または使用法エラー(コード1)[Receiver = 3.1.2]

私のテストシナリオでは、エラーメッセージは次のとおりです。

rsync: 変更ディレクトリ "/home/sciuro//home/sciuro/2021" 失敗: そのファイルまたはディレクトリがありません。 (2)エラー:複数のファイルをコピーするときは、ターゲットはディレクトリでなければなりません。 rsyncエラー:入力/出力ファイル、ディレクトリ選択エラー(コード3)main.c(641)にある[Receiver = 3.1.2]

これらのエラーは、--exclude *2020*ソースファイルとターゲットファイル/ディレクトリとは無関係にのみ発生します。以下のテストシナリオを参照してください。

ここで正確に何が間違っているかを説明できる人はいますか?

解決策は、次の間にパターンを挿入することです'--exclude '*2020*'

解釈され、このエラーを引き起こすrsyncの内部2020またはエンコーディングがあるようです。20


実際のシーン

この方法で実行すると、エラーは報告されません。

rsync -rtpogvlHbis --ignore-existing --progress --size-only --stats rsync://localhost:6010/root/sdcard/DCIM/Camera/ /media/sciuro/BCKP_WD4T/Fotos/2020/CELULAR/ -n --exclude *2021*
receiving incremental file list
.d...p..... ./
>f+++++++++ IMG_20201228_114334605.jpg
(...)

Number of files: 78 (reg: 77, dir: 1)
Number of created files: 77 (reg: 77)
Number of deleted files: 0
Number of regular files transferred: 77
Total file size: 4,191,721,673 bytes
Total transferred file size: 4,191,721,673 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 1,898
File list generation time: 0.013 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 270
Total bytes received: 2,147

sent 270 bytes  received 2,147 bytes  4,834.00 bytes/sec
total size is 4,191,721,673  speedup is 1,734,266.31 (DRY RUN)

これはない

rsync -rtpogvlHbis --ignore-existing --progress --size-only --stats rsync://localhost:6010/root/sdcard/DCIM/Camera/ /media/sciuro/BCKP_WD4T/Fotos/2021/CELULAR/ -n --exclude *2020*
Unexpected local arg: /media/sciuro/BCKP_WD4T/Fotos/2021/CELULAR/
If arg is a remote file/dir, prefix it with a colon (:).
rsync error: syntax or usage error (code 1) at main.c(1375) [Receiver=3.1.2]

テストシナリオ

これは最小限のテストです。

ソースディレクトリとファイル(ターゲットディレクトリが空です)

sciuro@toca:~$ ls test/origin/
Captura de tela de 2020-02-10 21-48-32.png
Captura de tela de 2020-04-02 21-14-44.png
Captura de tela de 2021-01-16 13-48-26.png
Captura de tela de 2021-01-16 13-48-27.png

1°テスト:目的地home/sciuro/2020/+--exclude *2021*

sciuro@toca:~$ rsync -rv /home/sciuro/test/origin/ home/sciuro/2020/ --exclude *2021* -n
sending incremental file list
created directory home/sciuro/2020
./
Captura de tela de 2020-02-10 21-48-32.png
Captura de tela de 2020-04-02 21-14-44.png
    
sent 144 bytes  received 64 bytes  416.00 bytes/sec
total size is 2,443,343  speedup is 11,746.84 (DRY RUN)

2°テスト[失敗]:目的地home/sciuro/2021/+--exclude *2020*

sciuro@toca:~$ rsync -rv /home/sciuro/test/origin/ home/sciuro/2021/ --exclude *2020* -n
    sending incremental file list
    rsync: change_dir "/home/sciuro//home/sciuro/2021" failed: No such file or directory (2)
    ERROR: destination must be a directory when copying more than 1 file
    rsync error: errors selecting input/output files, dirs (code 3) at main.c(641) [Receiver=3.1.2]

3°テスト:目的地home/sciuro/2021/+--exclude *2021*

sciuro@toca:~$ rsync -rv /home/sciuro/test/origin/ home/sciuro/2021/ --exclude *2021* -n
sending incremental file list
created directory home/sciuro/2021
./
Captura de tela de 2020-02-10 21-48-32.png
Captura de tela de 2020-04-02 21-14-44.png

sent 144 bytes  received 64 bytes  416.00 bytes/sec
total size is 2,443,343  speedup is 11,746.84 (DRY RUN)

4°テスト[失敗]:目的地home/sciuro/2020/+--exclude *2020*

sciuro@toca:~$ rsync -rv /home/sciuro/test/origin/ home/sciuro/2020/ --exclude *2020* -n
sending incremental file list
rsync: change_dir "/home/sciuro//home/sciuro/2020" failed: No such file or directory (2)
ERROR: destination must be a directory when copying more than 1 file
rsync error: errors selecting input/output files, dirs (code 3) at main.c(641) [Receiver=3.1.2]

解決策

 sciuro@toca:~$ rsync -rv /home/sciuro/test/origin/ home/sciuro/2021/ --exclude '*2020*' -n
    sending incremental file list
    created directory home/sciuro/2021
    ./
    Captura de tela de 2021-01-16 13-48-26.png
    Captura de tela de 2021-01-16 13-48-27.png
    
    sent 133 bytes  received 64 bytes  394.00 bytes/sec
    total size is 2,057,301  speedup is 10,443.15 (DRY RUN)

ベストアンサー1

引用符付き引数が必要です--exclude。それ以外の場合は、リリースホストで展開され、作業ディレクトリに相対的なglobと一致するローカルファイルが渡されます(たとえば、/media/sciuro/BCKP_WD4T/Fotos/2021/CELULAR/「実際の」シナリオでは)。

rsync -rtpogvlHbis --ignore-existing --progress --size-only --stats rsync://localhost:6010/root/sdcard/DCIM/Camera/ /media/sciuro/BCKP_WD4T/Fotos/2020/CELULAR/ -n --exclude '*2021*'

おすすめ記事