Filters and patterns - include specific folders

I know there are many posts about filters and patterns here, and they work for the most part.
But I was testing something today and tried the simplest folder include as described in the guide:

+foo/bar/*
+foo/
-*

In my case this was:

+C__Users_link/Public/*
+C__Users_link/
-*

C__Users_link is in the root of the repository and I needed to include single sub-folder in the backup.
It did not work.

Debug log contradicts what documentation states - "If a match with an include pattern is found, the path is said to be included without further comparisons."

INFO SNAPSHOT_FILTER Loaded 3 include/exclude pattern(s)
TRACE SNAPSHOT_PATTERN Pattern: +C__Users_link/Public/*
TRACE SNAPSHOT_PATTERN Pattern: +C__Users_link
TRACE SNAPSHOT_PATTERN Pattern: -*
DEBUG LIST_ENTRIES Listing
DEBUG PATTERN_INCLUDE C__Users_link is included by pattern +C__Users_link
DEBUG PATTERN_EXCLUDE C__Users_link/ is excluded by pattern -*

Am I missing something obvious here?

I believe this handling is wrong as C__Users_link is both a file and a folder (since it’s a symlink)

So i believe your real filters should be something similar to

+C__Users_link/Public/*
+C__Users_link/Public
+C__Users_link/
+C__Users_link
-*

or maybe swap the pairs (ie. file first then respective folder)

1 Like

Thank you, This is VERY non-obvious!

The following seems to work:

+C__Users_link/Public/*
+C__Users_link/
+C__Users_link
-*

The C__Users_link link is directory symlink, so it should be handled as folder, not file - it is followed as folder by :d: and is also restored as regular folder too.
I was not able to make regex pattern for this either, possibly because of the same issue. Will play with this tomorrow.

Your issue is related to Proposal: following symlinks by pattern (see the other 2 issues in OP)

Here is working regex:

i:(?i)^C__Users_link/Public.*
i:(?i)^C__Users_link$
i:(?i)^C__Users_link/$
e:(?i)^C__Users_link/.*$

It just emulates the original filters. It really should not be requited to have this over-complicated set of rules to include specific folder - especially when rules are to exclude everything which is not explicitly included. But that implicit exclusion should not stop processing of the folders, i.e. if we have

i:(?i)^C__Users_link/Public.*
C__Users_link
|______Public

Evaluating path C__Users_link or C__Users_link/ should not stop folder processing - because those are not excluded explicitly. Next folder enumeration will hit C__Users_link/Public which is explicitly included and should be marked for backup.
This is how people expect things to work :smile:
It would be great if filter engine would have relaxed match mode like this…

1 Like