Include patterns with wildcards

The wiki for Include/exclude Patterns includes the following:

Patterns may contain wildcard characters “" which matches a path string of any length, and “?” matches a single character. Note that both "” and “?” will match any character including the path separator “/”.

I believe the last sentence there may be what is tripping me up. My goal is to include the entire contents of my home dir recursively with one exception. I’d like to exclude the contents of each users’ TMP dir. The configuration I have been working with is as follows:

-home/*/TMP
+home/
+home/*

However, this is not producing the desired results. I suspect that the ‘*’ is matching greedily and therefore effectively excluding all the contents of the home dir. Is this correct? The only option I see to work around this is to specifically list out each user’s TMP DIR as follows:

-home/userA/TMP
-home/userB/TMP
-home/userC/TMP
# ... more users here
+home/
+home/*

This feels brittle at best (what if I forget to edit the filters file when a new user is added). Is there a better approach?

Is it safe to say that you should never have a "*’ anywhere in an Include/Exclude pattern except for the final character? If so, perhaps any such occurrence should produce an error or warning message as it is unlikely to produce the desired results.

TIA!

Maybe try to use the regex ignores?

home/[\w]*/tmp/

You can also test the filters file with something like this (not sure the exact form):

duplicacy -d -log backup -enum-only
1 Like

You just need to add a trailing / to -home/*/TMP, like:

-home/*/TMP/
+home/
+home/*

Without the trailing / the first exclude pattern will only work if TMP is a file.

Hi gchen,

Please excuse the typo in my original post. I do in fact have the trailing slash. However, it is still excluding all the contents on the home folder. Is there something else I am missing?

I set up a test dir and run duplicacy -d backup:

There are 0 compiled regular expressions stored
Loaded 3 include/exclude pattern(s)
Pattern: -home/*/TMP/
Pattern: +home/
Pattern: +home/*
Listing 
home/ is included by pattern +home/
Listing home/
home/user1/ is included by pattern +home/*
home/user2/ is included by pattern +home/*
Listing home/user1/
home/user1/file2 is included by pattern +home/*
home/user1/TMP/ is excluded by pattern -home/*/TMP/
Listing home/user2/
home/user2/file1 is included by pattern +home/*
home/user2/TMP/ is excluded by pattern -home/*/TMP/

I don’t see any issue here.

I suspect that the root cause of this issue is the symbolic links as described here https://forum.duplicacy.com/t/include-patterns-for-symbolic-links/1058/14