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
  • 616
  • 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. –  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

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
  • 91,753
  • I like & use a separate file. More info: http://askubuntu.com/questions/545655/backup-your-home-directory-with-rsync-and-skip-useless-folders and: http://askubuntu.com/questions/40992/what-files-and-directories-can-be-excluded-from-a-backup-of-the-home-directory/40997#40997 – 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 http://wiki.bash-hackers.org/syntax/expansion/brace – Cirelli94 May 03 '16 at 12:52
  • @FabrizioCirelli No problem :) – heemayl May 03 '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 03 '16 at 13:56
  • An unqualified "foo" would match a name of "foo" anywhere in the tree because the algorithm is applied recursively from the top down; it behaves as if each path component gets a turn at being the end of the filename. Even the unanchored "sub/foo" would match at any point in the hierarchy where a "foo" was found within a directory named "sub". See the section on ANCHORING INCLUDE/EXCLUDE PATTERNS for a full discussion of how to specify a pattern that matches at the root of the transfer. – Cirelli94 May 03 '16 at 13:56