1

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)
  • It looks as though, it's including the bracket into the directory name, why not include multiple --excludes, one for each path. And give it a try. – user508889 Apr 29 '16 at 14:06
  • I add an example! As you can notice, it doesn't exclude directories like .Trash-1000 in my example, even with one --excludes with each path – Cirelli94 Apr 29 '16 at 14:31
3

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 ....
  • I like & use a separate file. More info: askubuntu.com/questions/545655/… and: askubuntu.com/questions/40992/… – oldfred Apr 29 '16 at 14:48
  • @oldfred I also prefer that..neater.. – heemayl Apr 29 '16 at 14:52
  • Thank you very much. To integrate: An explanation about how braces works wiki.bash-hackers.org/syntax/expansion/brace – Cirelli94 May 3 '16 at 12:52
  • @FabrizioCirelli No problem :) – heemayl May 3 '16 at 12:53
  • if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname. This is similar to a leading ^ in regular expressions. Thus "/foo" would match a name of "foo" at either the "root of the transfer" (for a global rule) or in the merge-file’s directory (for a per-directory rule). – Cirelli94 May 3 '16 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.