How to exclude all hidden files and folders from duplicity backup

12,893

Solution 1

A hidden file or directory starts with a dot (e.g. .bash_history, .cache/). The pattern for that is .*, so you can use the --exclude '.*' option to exclude hidden files and directories. This option must come before other --include patterns because:

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.

(from man duplicity)

Solution 2

The decision by the developer is to keep the options very simple. This has been requested several times, here and here are some bug reports/feature requests on the issue.

An easier way to achieve what you want is to add just the directories (/Documents, /Music, /Pictures, etc...) individually, instead of selecting the entire /Home directory. You likely have 10 or less folders in your /Home directory, so this is easier then manually excluding all the hidden folders and files.

It's a good question, but the answer is to use a workaround.

Solution 3

In duplicity's GUI ("Backup" / deja-dup), if you want to list dot-file in your excluded files, you may be having difficulty selecting them via the GUI.

  1. Click on the plus ("+") icon under "Folders" tab and whichever category you wish (e.g. "Folders to ignore" category). This brings up a file browser.
  2. If you want to select dot files (ie, "hidden files"), just right-click in some empty space in this file browser and choose "show hidden files".
  3. Now you can make use of ctrl-click or shift-click to select some or many or all of your dot files explicitly.

This does NOT answer the question, but the other answers referred to command line non-solutions. This is a GUI non-solution.

Share:
12,893

Related videos on Youtube

ECII
Author by

ECII

Updated on September 18, 2022

Comments

  • ECII
    ECII almost 2 years

    How can I set duplicity to exclude all hidden files and folders from backing them up, without specifying each and every one of them?

  • Lekensteyn
    Lekensteyn over 12 years
    When excluding certain folders like --include Documents --include Music, do not forget to append --exclude '*' on the end or files will be included anyway.
  • Sanam Patel
    Sanam Patel over 12 years
    @Lekensteyn Good point. My answer is more geared for people like me who use duplicity via the 'Backup' GUI-based app. I actually upvoted your answer as it's the better one, but I see others have now upvoted mine. Bottom line is if people are setting this up via terminal they need to make sure the exclude command is used, right?