Is there a way to include a subfolder of an excluded parent folder?

If you need to get this working ASAP then you could consider making a symlink in a non-excluded part of the source tree that points to the file / folder in the excluded tree. If you do this, make sure you have --symlink-policy=follow set.

It’s not as flexible as a rule set, but it should do the trick.

And of course @kenkendk’s suggestion of including the Bookmarks file in the Source folders works, even if the parent of that file is excluded. For example, I tested the following and it worked:
Source folders (edited as text):

C:\Users\
C:\Users\MyUserName\AppData\Local\Google\Chrome\User Data\Default\Bookmarks

Filters (edited as text):

-[.:\\Users\\.*\\]

Partial results of “Commandline… -> Test filters”:

Including source path: C:\Users\
Including folder: C:\Users\
Excluding path due to filter: C:\Users\All Users\ => ([.:\\Users\\.*\\])
Excluding path due to filter: C:\Users\Default\ => ([.:\\Users\\.*\\])
Excluding path due to filter: C:\Users\Default User\ => ([.:\\Users\\.*\\])
Excluding path due to filter: C:\Users\Default.migrated\ => ([.:\\Users\\.*\\])
Excluding path due to filter: C:\Users\MyUserName\ => ([.:\\Users\\.*\\])
Excluding path due to filter: C:\Users\Non-Admin\ => ([.:\\Users\\.*\\])
Excluding path due to filter: C:\Users\Public\ => ([.:\\Users\\.*\\])
Including file: C:\Users\desktop.ini (174 bytes)
Including source path: C:\Users\MyUserName\AppData\Local\Google\Chrome\User Data\Default\Bookmarks
Including file: C:\Users\MyUserName\AppData\Local\Google\Chrome\User Data\Default\Bookmarks (112.07 KB)
Matched 2 files (112.24 KB)
Return code: 0

OK, last idea - as stated on the Filters page linked to above, in the case of all filters being INCLUDE filters, everything else will be EXCLUDED.

So if you have a Source of:

C:\Users

Then filters of:

+[.:\\Users\\[^\\]*\\Documents\\]
+[.:\\Users\\[^\\]*\\Desktop\\]
+[.:\\Users\\[^\\]*\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Bookmarks]

It should include ONLY the Documents & Desktop folders and the Google Chrome Bookmarks file.

HOWEVER - you may find your file scans take longer as now every file in the C:\Users tree will have to be scanned and have the filters applied to them (vs. folder level exclusions filters where all files in a subfolder can flat out be ignored so don’t need to be scanned).


@kenkendk, I wonder if would be a “good thing” to add a “~” or “^” prefixed filter that basically says “apply this include filter BEFORE the folder level filters”.

It is hard enough as it is to guess at what the filters do. If we start to allow partial priority change, I think it will be really hard to grasp.

Whenever we have had discussions like this in the past, I suggested that we include python scripting support. Then you are free to write super complex filters that can be easily debugged. It should be fairly simple to do as there is an IronPython runtime that will allow this.

1 Like

Thank you for your help!
as i mentioned before, including as source folder is not the best idea in multi user evironment.
Anyway, it will be great, if in the future you can add

  1. queue (use filter set number 1, then 2)
    or
  2. prefixed filter that basically says “apply this include filter BEFORE the folder level filters”.
    or
  3. add regular expression or syntaxis in the source folder window (select drive C:\ and c:\users*\appdata\local\Google\Chrome\User Data\Default\Bookmarks

and it would be great, if someone can add here https://www.duplicati.com/articles/Filters/ some description about regular expression usage with some examples

at the moment i decided to use aprox 40 exclusion in exclude filter as a temporary solution

I am facing the same problem and have tried many things yesterday.

I tried the same and it was already close to the solution. My backup job now looks like this:

Include: c:\Users
Exclude regular expression: .:\\Users\\[^\\]+\\AppData\\Local\\(?!IWantThis_1\\|IWantThis_2\\|A_Subfolder\\IWantThis_3\\).+[^\\]$

I think a .+[^\\] at the end did the trick. If you use .* instead, it may also be that no character follows. So already c:\Users\AppData\Local\ is matching and Duplicati does not crawl the subdirectories anymore. But with .+ it is enforced that at least one character must follow and so Duplicati also looks into the subdirectories. The trailing [^\\]$ is needed so that deeper directory levels can be browsed. Otherwise “A_Subfolder\IWantThis_3” would not work, because already at "A_Subfolder" Duplicati would stop crawling.

The disadvantage is that each individual file must be checked against this regular expression, which can increase the runtime of the backup. The second disadvantage is that the entire directory structure is backed up, but without files.