4

I'm trying to only backup specific files with Duplicity so I first used this command:

duplicity /source-path --include "**/*/*.txt" --include "**/*/*.xml" /dest-path

However this gives the following error:

Last selection expression:
    Command-line include glob: **/*/*.txt
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.

Then I tried to exclude everything and then include just what I need:

duplicity /source-path --exclude "**/*" --include "**/*/*.txt" --include "**/*/*.xml" /dest-path

But I'm still getting the same error. How would I go about doing this, basically only backup the .txt and .xml on the source?

5

In the long description of the many variants of how to include and exclude files, there seems to be one most important sentence:

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

According to this, you need an include option for the files you want first, so they are matched there, and the first match can no longer be an exclude. The, have an exclude option to match everything. The files matched before will not be affected, but everything else is excluded now:

 duplicity ... --include "**/*/*.txt" --exclude "**/*" src dest

For your example, that would be

 duplicity /source-path --include "**/*/*.txt" --include "**/*/*.xml"  --exclude "**/*" /dest-path

To understand which files are matched, you can use dry runs, not changing anything, with logging to list matched files:

duplicity --dry-run --no-encryption -v info --include ... --exclude ... src dest


From man duplicity:

 FILE SELECTION
        duplicity accepts the same file selection options rdiff-backup does,
        including --exclude, --exclude-filelist-stdin, etc.

        When duplicity is run, it searches through the given source directory
        and backs up all the files specified by the file selection system.  The
        file selection system comprises a number of file selection conditions,
        which are set using one of the following command line options:
               --exclude
               [  ...  ]
               --include-regexp
        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.

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.