# Can I make a backup respect CACHEDIR.TAG?

**URL:** https://forum.duplicati.com/t/can-i-make-a-backup-respect-cachedir-tag/924
**Category:** Support
**Created:** [October 6, 2017, 1:15am UTC](https://forum.duplicati.com/t/can-i-make-a-backup-respect-cachedir-tag/924 "2017-10-06T01:15:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Eric\_Monson](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/e/b2d939/32.png) [@Eric\_Monson](https://forum.duplicati.com/u/Eric_Monson)
#### Post date: [October 6, 2017, 1:15am UTC](https://forum.duplicati.com/t/can-i-make-a-backup-respect-cachedir-tag/924/1 "2017-10-06T01:15:08Z")

</div>

As in the title, I can see a number of options for filters, but I can’t think of a way to make CACHEDIR.TAG work on my backups without actually running a script to generate new excludes and copying it in before the backup runs.

“Exclude directories whose names contain” or “Exclude files whose names contain” wouldn’t work, for example, but they’re only a step away from “Exclude directories containing files whose names contain” when seen together…

The regular expression options seem like the best match, though, if there’s a way to match against a full path, while reducing the result to something smaller. I don’t know if there is, but I can’t seem to find docs indicating that it’s possible. If I could simply set up some kind of search/replace thing for the filter rules, that would be great. For instance, if the regex options had two fields with the second one specifying the the actual filtered element from the match. This second field would default to the whole match, but you could use a string with a backreference to adjust the filter to what you needed. With this, I could use “(.\*/)CACHEDIR.TAG” for the first field (the match) and “\1” for the other and have exactly what I needed.

Honestly, if there was just somewhere I could put a text file containing exclude filters, I could use run-script-before-required to generate that as needed, and then I could have essentially unlimited flexibility in generating filter rules on demand (though that would be best if Duplicati passed in or otherwise made available details about the backup’s other options, such as sources to consider). That seems like the most enticing idea to me if there isn’t any way to do this already, but I’m actually hoping that there’s already something that would let me accomplish this

---

<div class="post-metadata">

### Author: ![JonMikelV](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@JonMikelV](https://forum.duplicati.com/u/JonMikelV)
#### Post date: [October 6, 2017, 3:28am UTC](https://forum.duplicati.com/t/can-i-make-a-backup-respect-cachedir-tag/924/2 "2017-10-06T03:28:08Z")

</div>

It sounds like you want what has been discussed (but not yet implemented) here:

> [@\[Suggestion\] Filter "Exclude folder if it contains a file xy" just like .nomedia](https://forum.duplicati.com/t/suggestion-filter-exclude-folder-if-it-contains-a-file-xy-just-like-nomedia/750):
>
> Hey I have got a suggestion. You know, in Android folders are avoided for picture indexation if they have a file “.nomedia”. –\> Duplicati could avoid backup of folders (and subfolders) if folder contains a specific file. I.e. let us add a filter: "Exclude folder if it contains a file called… []" And we can define our own standard.

Since it sounds like you’re comfortable with `run-script-before-required`, until that feature is added I believe you CAN set a `DUPLICATI__FILTER="-[Folder1]:-[Folder2]"` environment variable which Duplicati SHOULD obey on startup.

Note that I haven’t actually tested this myself, so I could be wrong in the functionality OR the formatting.
