I have this rsync command that I use for years to backup photos from my smartphone. It runs normally except if I swap --exclude *2021*
to --exclude *2020*
In my real scenario, the error message is
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]
And in my test scenario, the error message is
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]
These errors only happens with --exclude *2020*
independently of source and destination files/directories. Please have a look at my test scenario bellow.
Anybody can explain me what's exactly is the problem here?
The workaround was to insert the pattern between '
: --exclude '*2020*'
I'm guessing that rsync has some internal 2020
or 20
encode that is being interpreted and leding to this error.
Real scenario
This run without error
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)
This doesn't
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]
Test scenario
Here is a minimal test.
Origin dir and files (destination dir are empty)
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° test: destination 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° test [FAIL]: destination 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° test: destination 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° test [FAIL]: destination 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]
The workaround
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)