2

I run this cmd to backup my folders:

$ rsync -av --exclude {/mnt/dati/Film/, /mnt/dati/Scout/} --delete /mnt/dati/ /media/cirelli/HD1TB/backup/dati
sending incremental file list

And rsync answer is:

rsync: link_stat "/mnt/dati/Scout/}" failed: No such file or directory (2)

but "Scout" directory exist! Can't understand what I mistake. Even Film is copied, even if there isn't any error message! What's wrong in my execution of rsync?

Thank you very much folks

(oh, I have read man https://download.samba.org/pub/rsync/rsync.html and examples http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/ but still find any way to solve..!)

I also tried (this is interrupted by CTRL+C):

cirelli@asus:~$ rsync -av --exclude /mnt/dati/Film/ --exclude /mnt/dati/.Trash-1000/ --delete /mnt/dati/ /media/cirelli/HD1TB/backup/dati
sending incremental file list
deleting Documenti/script/
rsync: readlink_stat("/media/cirelli/HD1TB/backup/dati/Documenti/RPi/.2015-05-05-raspbian-wheezy.zip.2sXers") failed: Input/output error (5)
deleting Documenti/RPi/KODI/
deleting Documenti/RPi/berryboot-20130908.zip
deleting Documenti/RPi/2015-05-05-raspbian-wheezy.zip
IO error encountered -- skipping file deletion
.Trash-1000/files/
.Trash-1000/files/2015-05-05-raspbian-wheezy.zip
.Trash-1000/files/berryboot-20130908.zip
.Trash-1000/files/settembre 12.img
^Crsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(632) [sender=3.1.1]
rsync: [sender] write error: Broken pipe (32)
Cirelli94
  • 626
  • 1
  • 6
  • 26

1 Answers1

7

The first problem is in your brace expansion {}, which is done by the shell and rsync is just using the result.

You have made the brace expansion an no-op by introducing a space between the directory names, so to rsync the --exclude option has become:

--exclude {/mnt/dati/Film/,

so rsync will exclude the file (or directory) {/mnt/dati/Film/, (presumable there is no such) and the /mnt/dati/Scout/} has become a source file to copy for rsync and there no such file/directory, hence the error message.

To solve this brace expansion issue, you need to remove the space between the directory names:

{/mnt/dati/Film/,/mnt/dati/Scout/} ....

Or better just use the common part once:

/mnt/dati/{Film/,Scout/} ....

But this does not solve the problem with rsync because --exclude takes a pattern like:

--exclude='foo*bar'

or

--exclude 'foo*bar'

so in this case too, the directory /mnt/dati/Scout/ will still be taken as a source directory to copy from.

To solve this problem too you can use multiple --exclude:

rsync -av --exclude=/mnt/dati/Film/ --exclude=/mnt/dati/Scout/ ....

Or save the patterns in a file and use:

rsync -av --exclude-from=/file/with/patterns ....
heemayl
  • 93,925