0

The duplicity documentation doesn't appear to fully document its behaviour when relative paths (or bare filenames) are passed to the --exclude option. If I pass the option --exclude foo, for example, will this cause each file or directory named foo in the entire heirarchy under source_directory to be excluded, or will it only exclude a file or directory with that name in source_directory itself? If the latter is the case, is there a way to exclude source_directory/foo without having to type the full path to source_directory for each such option (other than by using a shell variable)?

1
  • For a src dir of a/b/c you could use --exclude */*/*/foo where the number of */ matches the src, but it is probably simpler as you say to use a variable. Note if you try --exclude foo with the above src you'll get an error FilePrefixError as the pattern foo is tested against the src.
    – meuh
    Sep 3, 2021 at 18:16

1 Answer 1

0

been a while since i looked at duplicity in/exclusion. but generally duplicity 0.8 man page, section File Selection describes it pretty well.

duplicity only in/excludes during backup currently . all in/exclusions need to be absolute paths or contain wildcards as descibed in the man page. if you define a relative path duplicity will show an error like

Fatal Error: The file specification
    foo
cannot match any files in the base directory
    /home/user/

you asked

If I pass the option --exclude foo, for example, will this cause each file or directory named foo in the entire heirarchy under source_directory to be excluded, or will it only exclude a file or directory with that name in source_directory itself?

neither nor. it will err out as shown above. if you want to exclude e.g. /home/user/foo when backing up /home/user/ you will need to exclude it absolutely --exclude /home/user/foo . if you want all foo folders/files excluded you may use --exclude '**/foo' where '**' stands for any path.

If the latter is the case, is there a way to exclude source_directory/foo without having to type the full path to source_directory for each such option (other than by using a shell variable)?

No, unfortunately you will need to give it (plain or as env var), redundant as it may seem. if you have lot's of exclusions consider using --exclude-filelist which my contain in/exclusions albeit it's naming. Also there is --exclude-if-present which allows you to give a file name that indicates that a folder is to be excluded if it contains a file named thus.

hope that helps ..ede/duply.net

1
  • The documentation includes an example where a relative path is used: in the section toward the end covering the filelist options, the lines dir/foo and + dir/bar are used. The manual explains that --include-filelist list.txt would be exactly the same as specifying --include dir/foo --include dir/bar --exclude ** on the command line.
    – intuited
    Sep 3, 2021 at 17:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .