I am backing up a folder that has subfolders with names like “something_data”. It has other folders I don’t want, so I set up an include filter: *_data\**
. The problem is the other folders that I don’t want themselves have subfolders called “_data” and Duplicati is seeing the nested folders and including them. I only want Duplicati to see the root “XXXX_data” folders and select those, but I have been trying for hours and can’t get such a simple thing to work. My filter either includes any folder anywhere with “_data” in it, or includes nothing, depending on how I configure it.
Well, I’m glad I asked because I immediately figured out something that almost works!
I added an exclusion for **\_data\
. I don’t know why I didn’t think of that one before. I guess I assumed it was going to exclude the _data folders in the folders that I do want. But it does in fact correctly backup all the folders and files I want.
The only remaining problem is that for some reason it also backs up all files in the root plus all the folders I don’t want but not their contents! I guess that’s because actually ever folder has a subfolder called _data. So that means that really my include rule isn’t doing anything, just the exclusion rule is working…
OK, wow, I finally stumbled into the solution.
+[.+_data\\.*]
-*\
-*
I kind of don’t understand how it works or why it is necessary. Maybe I don’t need to use a regex for the first one, but it helps to avoid folders that are only called _data without a prefix. For some reason the exclusion rules are still necessary to exclude all other folders and files in the root, even though the documentation says that if you only have inclusion rules then everything else is supposed to get excluded by default.
I can try to break it down a bit. Duplicati evaluates each path to a folder/file one at a time. For each path it evaluates each filter entry. If there is a match, it will not look at the rest of the filters. Additionally, it uses the convention that directory paths ends with \
(or /
on MacOS/Linux).
The two excludes thus excludes all folders and all paths respectively. You can omit the -\
filter because the -*
also matches folders
The first include, includes anything that has at least one character and then _data\
in the path.
I think your solution is close to optimal, because you do not need to look at subpaths.
Thanks. So according to your explanation it must be a breadth first search. In the end the solution is so simple, I don’t know why I had to struggle with it for hours. According to the documentation if you only have include rules than everything else should be excluded automatically, but it doesn’t seem to actually work that way.