15

I'm using duplicity to backup some of my files. The man page is kind of confusing, regarding the include/exclude Patterns. I'd like to backup the following things:

/storage/include
/otherthings

but NOT

/storage/include/exclude

The Include-File currently looks:

+ /storage/include
- /storage/include/exclude
+ /otherthings
- ** 

Duplicity is called as followed:

/usr/bin/duplicity --include-globbing-filelist /Path/to/file/above / target

It simply doesn't work. Every time it backups, it also includes the files in /storage/include/exclude.

Nemo
  • 522
  • 1
  • 11
  • 23
int2000
  • 253
  • 1
  • 2
  • 6
  • How do you know that is the syntax of the include-file? Also, maybe this would work: `duplicity --exclude-filelist "/Path/to/filelist/without-or+/to-exclude" / target`. (note: I don't use `duplicity`, just a suggestion based on the manual page I found) – JMCF125 Mar 02 '14 at 12:00

1 Answers1

16

The file selection section of the duplicity man page states:

Each file selection condition either matches or doesn’t match a given file. 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.

This relates to the --include / --exclude command line options priority, but the manual page later you find the relevant info for the --include-globbing-filelist option you use:

The --include-globbing-filelist and --exclude-globbing-filelist options also 
specify filelists, but each line in the filelist will be interpreted as a
globbing pattern the way --include and --exclude options are interpreted
(although "+ " and "- " prefixing is still allowed). For instance, if the
file "globbing-list.txt" contains the lines:

    dir/foo
    + dir/bar
    - ** 

Then --include-globbing-filelist globbing-list.txt would be exactly the same
as specifying --include dir/foo --include dir/bar --exclude ** on the command
line. 

What happens is that /storage/include/exclude matches the first line, it therefore it is included. You should in general use more specific statements before less specific ones. The following should work for you:

- /storage/include/exclude
+ /storage/include
+ /otherthings
- ** 
Anthon
  • 78,313
  • 42
  • 165
  • 222
  • Nice. It works. One more question: If i only want to exclude, say "txt"-Files in the exclude-Directory. How do i do this? - /storage/include/exclude/*.txt didn't work – int2000 Mar 02 '14 at 14:56
  • @int2000 That should IMHO work, but such patterns are not explicitly [tested](http://bazaar.launchpad.net/~duplicity-team/duplicity/0.6-releases/view/head:/testing/tests/selectiontest.py#L319). So there might be an issue. Could you use `/storage/include/exclude/**.txt`, or at least try if that works. If not you might have found a bug in the matching code in selection.py – Anthon Mar 02 '14 at 15:36
  • How does this relate to the source parameter of the duplicity command? Would the dir/foo in your first example be /source/path/dir/foo ? – ñull Nov 18 '20 at 12:38