How do I specify a wildcard string for the end/trailing of a folder

Question

I want to only match wildcard folders but not wildcard files.
**/*cache or even **cache works for folders prepended with cache
but
**/*cache*/ doesn’t work to match only folders because the trailing / is ignored
Is there anyway to get around this?

Reference

From Documentation https://restic.readthedocs.io/en/latest/040_backup.html
A trailing / is ignored, a leading / anchors the pattern at the root directory. This means, /bin matches /bin/bash but does not match /usr/bin/restic.

Welcome here @Unequal8761 !

The ignore system makes no distinction between files and directories. The patterns you specify are checked against files and directories alike.

Does that mean restic checks the file path of every file in the provided directory regardless of exclude?

Some more context. I get error:

incomplete metadata for C:\ProgramData\Dropbox\Update\Log\DropboxUpdate.log-2025-04-20-05-45-16-090-12840:

even thought I have \ProgramData\Dropbox in my excludes

@Unequal8761, for that example your exclude should be C:\ProgramData\Dropbox so with the drive letter included.

Note that restic is case sensitive so also use the same case (I recommend all in uppercase) for the backup command drive letters..

1 Like

For my own sanity. I tested it.

@Unequal8761
since your original question was:

I want to only match wildcard folders but not wildcard files.

Can you help summarize your findings, if it helped anything towards your question?
Do I observe correctly that since there are 8 folders in your example tree, all green exclude combinations would work for you?

There’s a feature request to allow excludes to only match folders: Allow excluding/negative-excluding directories only – give meaning to trailing slashes · Issue #4399 · restic/restic · GitHub

1 Like

My initial concern was how long it would take to run a backup. My perspective is that backup time is directly correlated with how many files that have to be processed when the files are small. When the files are large that may be the limiting factor. I seem to have a lot of small files in directories like node_module directories and wanted to limit that. The green ones are what I wanted to see. I overwhelmed the excluded folders because I wanted to see how many of those directories were getting scanned completely.

The surprising one to me was T:\** as a prefix. T:\**excluded* seems to process all the files in the following, even though I would expect it completely safe to skip them because ** is any path:

  • folder/excluded
  • folder/folder/excluded

Limitations:
My provided folder structure might not be complete enough as I made it for one purpose.

That pattern is nonsensically. ** must be enclosed between directory separators or it won’t work. So you’re pattern is probably equivalent to T:\*excluded* (* does NOT match directory separators). Based on your example paths you actually wanted T:\**\excluded* (whatever that trailing * is supposed to match).

To only exclude files in e.g. node_modules but keep the folder, you could use the following: **/node_modules/*.

I made this pull request on the documentation but now I’m not sure if it’s correct because of being able to prefix with ** docs: clarify ** wildcard must me between path separators by rhhub · Pull Request #5400 · restic/restic · GitHub