2

I am using rdiff-backup. Really awesome simple powerful backup tool. However I am fighting with wildcard glob patterns. I have this directory structure:

/data/aaa/cache
/data/bbb/cache
/data/ccc/cache
etc....

In each cache directory are original files and cache files. Original files are named simply 1.jpg, 2.png, 3.gif, and so on. Cache files have some string attached to the original filename.

So I want to backup all the /data/*/cache directories, but to include only original files, not the cache files.

I am using this command:
rdiff-backup --exclude **/cache --include **/cache/+([0-9]).+([a-z]) /data /backup

But rdiff-backup returns this and I am lost:

Found interrupted initial backup. Removing...
Fatal Error: Last selection expression:
    Command-line include glob: **/cache/+([0-9]).+([a-z])
only specifies that files be included.  Because the default is to
include all files, the expression is redundant.  Exiting because this
probably isn't what you meant.
David Eisenstat
  • 64,237
  • 7
  • 60
  • 120
Frodik
  • 14,986
  • 23
  • 90
  • 141

2 Answers2

3

You might want to do a two step process:

  1. create a list of all files you want to exclude e.g. with find . -name "**/cache" > excludes.lst
  2. use the list with --exclude-filelist excludes.lst

This way you can avoid fighting with the glob option and you have full control over your excludes

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
2

From http://rdiff-backup.nongnu.org/rdiff-backup.1.html :

   A given file is excluded by the file selection system exactly
   when the first matching file selection condition
   specifies that the file be excluded; otherwise the file is included.

...

   For instance,

          rdiff-backup --include /usr --exclude /usr /usr /backup

   is exactly the same as

          rdiff-backup /usr /backup

   because  the  include  and  exclude  directives  match exactly the same
   files, and the --include comes first, giving it precedence.

So, in your case, it is complaining about the final --include because if a file gets there (i.e. it isn't matched by the previous --exclude) it will be included whether or not it matches the --include. That's what the error message was trying to say.

As for how to accomplish your goal...

Assuming you do want to exclude only paths of the form: /data/*/cache/[0-9]*.[a-z][a-z][a-z]?* just specify that:

rdiff-backup --exclude '/data/*/cache/[0-9]*.[a-z][a-z][a-z]?*' --exclude '*' /data /backup

This should work (I haven't tested it).

  • 1
    Thanks for your effort, however I can't use your solution, because my scenario is little bit complicated. I have simplified it for the sake of this question. In my real example, I am backing up more directories so I can't use `--exclude '*'`, because I generally need to include them all, not exclude them all. Hope, if you can modify your answer. Thanks again – Frodik Oct 18 '14 at 19:29
  • So which files & directories *do* you want to exclude, exactly? Just the cache files? – Jesse W at Z - Given up on SE Oct 21 '14 at 18:52
  • Well, here's a possible answer... hope you're still listening. – Jesse W at Z - Given up on SE Oct 28 '14 at 21:49