Help with filters on a network share

Hello all,

I’m trying to configure duplicacy in order to backup a windows network share from a linux Ubuntu.
My share is named /media/driveg.
Since I don’t want to see duplicacy files in the share, I’m backing up /media given that folder contains only the driveg folder.

My goal is to set up the filters to backup only some folders of /media/driveg an since it’s a share polluted with Windows and Mac temporary files, I want to exclude a bunch of files.

My Filter file looks like this:

# exclude .* files or folders
-.*

# exclude *.tmp files
-*.tmp

# exclude *.lnk files
-*.lnk

# exclude desktop.ini files
-desktop.ini

# exclude Thumbs.db files
-Thumbs.db

# Folders
+driveg/FolderA/
+driveg/FolderB/
+driveg/FolderC/
+driveg/FolderD/
-driveg/*

Unfortunately:

  • Files that start with dots are not excluded. Reason in the dry run: because +driveg/FolderA/ allows it
  • Same for almost all files
  • I want to backup FolderA to FolderD and exclude anything else but “-driveg/*” in the end blocks everything

Anyone know how I can exclude files and folders no matter where they are ? And only include my 4 folders ?

Thank you very much.

Try this:

# exclude .* files 
-.*
# exlcude .*/ folders
-.*/

# exclude *.tmp files
-*.tmp

# exclude *.lnk files
-*.lnk

# exclude desktop.ini files
-*/desktop.ini

# exclude Thumbs.db files
-*/Thumbs.db

# Folders
+driveg/
+driveg/FolderA/*
+driveg/FolderB/*
+driveg/FolderC/*
+driveg/FolderD/*
-*

Note, this is GLOB syntax, you can use regex as well if you want.

1 Like

Taking this as a practice exercise in duplicacy filtering (I still haven’t quite wrappend my head around how it works, or I keep forgetting it, since my filters change rarely).

So here is my take:

+driveg/FolderA/ should not be including any files, only the folder (+driveg/FolderA/* would include the folder and its contents)

This only excludes .* files in the repository’s root directory. Excluding them everywhere else would require something like -*/.*

Is that what we want? I read

as meaning: I want to exclude foo/.bar regardless of whether it is a file or a directory. But do directories need an extra filter?

For some reason I seem to remember that +drivreg/ should come after rather than before the folders (A, B, C, …) that we actually want to include. It’s counterintutive but that’s why I made the mental note.
In any case: the important part in saspu’s version is, of course, the asterisk as mentioned above.

I think what was confusing you when diagnosing your original setup was that you thought that the stuff you wanted to include was included because of +driveg/FolderA/ etc, while it actually was included because it wasn’t excluded. Which is why @saspus added

to exclude everything else. Without that, none of the + filters has any effect.

I’m not sure, though, whether this will include desktop.ini in the repository root… I’d probably use a regex to ensure that.

Edit: found the reason for my mental note above: See this post: Improving the instructions for include/exclude patterns (filters)

1 Like

My understanding is without trailing slash will match files, and with - directories.

Oh, so true. The globs are easy but dangers, because * includes /

With regex there is some learning curve (I highly recommend this mini course https://regexone.com), but the rules are unambigous, logical, and precise:


# Starting with period, followed by any number of characters other than /, and optionally trailing / and end of line
e:^\.[^/]*/?$

# exclude specific extensions: match the period followe dby ink or tmp and end of string
e:\.(lnk|tmp)$

# exclude specific files: optional path ending with / before or nothing before desktop.ini or thumbs db 
e:^(.*/)?(desktop.ini|Thumbs.db)$

# Include driveg/, driveg/FolderA/, drivegFolderA/....
i:^driveg/((FolderA|FolderB|FolderC|FolderD)/.*)?$

# exclude everything else
-*

You can play with regex here https://regex101.com

And as a side note, I would not exclude desktop.ini

Thank you both for your input.
I’ve used @saspus syntax with a few modifications and it works as expected.