Exclude filter syntax - quick request for anyone who already has urbackupclient compiling in Windows

TL;DR request for anyone who has urbackupclient working in visual studio:
Please ensure you have at least one backup exclude rule, then make a breakpoint at client.cpp line 3713

bool b=amatch(wpath.c_str(), exclude_dirs[i].c_str());

I need to know exactly what the string wpath looks like in this moment.


Long version:
I’m setting up urBackup for my environment, going through all the options meticulously. I am trying to set some complex exclude rules, but I need to know the specifics of the syntax to know what is possible. I figure the best way to do this is directly from the source. I pulled the amatch function from glob.cpp and wrapped it in a command line tool to experiment. Either I am totally off on something, or Windows (backslash) matching is broken:

$ ./m "c:\\test.sys" "*.sys"
Excluded
$ ./m "c:\\test.sys" "test.sys"
No match
$ ./m "c:\\test.sys" "c:\\test.sys"
No match
$ ./m "c:/test.sys" "c:/test.sys"
Excluded

Even the windows paths in test_amatch break if you reverse the slashes

$ ./m "Users/Bernd/bla/Documents/xyz" "Users/:/:/Documents/*"
Excluded
$ ./m "Users\\Bernd\\bla\\Documents\\xyz" "Users\\:\\:\\Documents\\*"
No match

The only way this makes sense is if all backslashes are changed to forward slashes before comparison in both the file path and exclude filter, but that seems to contradict the help page

“Use a backslash for Windows clients ( "\" ) and a forward slash for Linux clients ( "/" ) to separate folders.”

and makes half the tests in test_amatch pointless.

Welp, I just found parseExcludePatterns and sanitizePattern, which apparently replaces all instances of "/ and “\” with “\\” on Windows, which somehow allows amatch to work normally.

$ ./m "Users\\Bernd\\bla\\Documents\\xyz" "Users\\:\\:\\Documents\\*"
No match
$ ./m "Users\\Bernd\\bla\\Documents\\xyz" "Users\\\\:\\\\:\\\\Documents\\\\*"
Excluded

I see it also first adds “*\” to any entries that are just a full file name, which explains

$ ./m "c:\\test.sys" "test.sys"
No match

I think I have enough to go on now.

EDIT: You have no idea how happy I was to see this works:

$ ./m "c:\users\testuser\appdata\local\google\chrome\user data\shadercache\gpucache\data_0" "c:\\\\users\\\\:\\\\appdata\\\\local\\\\*cache*"
Excluded
$ ./m "c:\users\testuser\appdata\local\mozilla\firefox\profiles\hntxkxrf.default\offlinecache\index.sqlite" "c:\\\\users\\\\:\\\\appdata\\\\local\\\\*cache*"
Excluded

Good luck, UrBackup has the most user unfriendly exclude system I’ve ever encountered. Even clam-win which uses a similar horrible syntax at least lets you enter excludes one per line, instead of a four mile string you can only see 4 inches of.

I don’t think it could be made more difficult & error prone even if the devs set out deliberately to do so.

1 Like

That’s just a fault of the GUI. The config file stores it in a single line because that keeps ISettingsReader simple. The web GUI doesn’t actively break it out because no one has bothered to implement that. Not too important for me, I just use Notepad++ to convert to newline separated to make changes, then back to comma separated to paste into the box.

I think it needs something like :
a text area
multiple one line inputs
an ignore file (like duplicity : you put a special file in a directory it wont backup it, nor anything under it).

Currently on my personal computer the ignore pattern is so long the browser slows down when i put my cursor in that box )

Microsoft took 30 years to fix this issue in the environment variable editor, so cut me some slack :wink:

This is also a relatively self-contained problem and UrBackup is Open Source, so help would be appreciated!

Well my personal computer has 216 ignore filters, so i can understand that doesn’t help at all.

For contributing, i tried to look at it, i am a sysadmin and doing c/cpp not in the range of what i can do, so i tried to help peoples on the forums and providing bug reports.