How to include / exclude directories in duplicity

19,059

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
- ** 
Share:
19,059
int2000
Author by

int2000

Updated on September 18, 2022

Comments

  • int2000
    int2000 almost 2 years

    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.

    • Ievgen Chuchukalo
      Ievgen Chuchukalo over 10 years
      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)
  • int2000
    int2000 over 10 years
    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
  • Anthon
    Anthon over 10 years
    @int2000 That should IMHO work, but such patterns are not explicitly tested. 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
  • ñull
    ñull over 3 years
    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 ?