# I do not want to back up cache directories. How can I exclude them?

**URL:** <https://kopia.discourse.group/t/i-do-not-want-to-back-up-cache-directories-how-can-i-exclude-them/1500>\
**Category:** General Topics\
**Created:** [October 24, 2022, 5:58pm UTC](https://kopia.discourse.group/t/i-do-not-want-to-back-up-cache-directories-how-can-i-exclude-them/1500 "2022-10-24T17:58:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angler](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Angler](https://kopia.discourse.group/u/Angler)\
**Post date:** [October 24, 2022, 5:58pm UTC](https://kopia.discourse.group/t/i-do-not-want-to-back-up-cache-directories-how-can-i-exclude-them/1500/1 "2022-10-24T17:58:25Z")

</div>

A significant portion of my backup is this Library/Caches folder. I don’t see a reason to back this up.

 ![image](https://global.discourse-cdn.com/free1/uploads/kopia/original/1X/46065c831cd482e5eb9b901ea007bec06ecb9816.png)

macOS, KopiaUI v0.12.1

My global policy

 ![image](https://global.discourse-cdn.com/free1/uploads/kopia/original/1X/9ba73de70181ea68360d5ec6b1a5ee102f8632e3.png)

I have also placed a .kopiaignore file in ~/Library/Caches/ and it still gets included in snapshots.

I tried [this recommendation](https://kopia.discourse.group/t/how-to-ignore-directories/497/3), but I’m still getting these cache dirs backed up.

`kopia policy set --global --add-ignore .cache --add-ignore cache --add-ignore Caches`

I have also configured my local snapshot policy,

 ![image](https://global.discourse-cdn.com/free1/uploads/kopia/original/1X/d4cd26a0b55715b60c91f738ba64ff538e772b27.png)

What can I do to prevent backing up cache directories? I would like to exclude them please. I thought that somehow, at least one of the methods I tried might help. No joy.

Curious, what does .kopiaignore do? My (obviously incorrect) assumption was that if a directory contained an empty file named .kopiaignore in it, that directory and its subdirectories would be ignored and would not be included in a snapshot. What does it do instead?

---

<div class="post-metadata">

**Author:** ![manfredlotz](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/manfredlotz/32/175_2.png) [@manfredlotz](https://kopia.discourse.group/u/manfredlotz)\
**Post date:** [October 25, 2022, 5:49am UTC](https://kopia.discourse.group/t/i-do-not-want-to-back-up-cache-directories-how-can-i-exclude-them/1500/2 "2022-10-25T05:49:22Z")

</div>

Your `kopia policy...` command can not work obviously. You exclude `.cache` and the directory name on macOS is `Caches`.

When kopia finds a file `CACHEDIR.TAG` in a directory then this directory will not be backed up.

I first would check if such a file exist already in `~/Librariy/Caches` with for example

```auto
find ~/Library/Caches -name CACHEDIR.TAG

```

If you really want to exclude the whole directory `Caches` then copy one of those `CACHEDIR.TAG` files to `~/Library/Caches`.

But I wouldn’t do it. I would check for large directories without `CACHEDIR.TAG` and then decide if it is a good idea to exclude. Just my 2 cents.

I guess that `kopia` does create such files automatically in its cache directories. At least it does here (Linux).

---

<div class="post-metadata">

**Author:** ![Angler](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Angler](https://kopia.discourse.group/u/Angler)\
**Post date:** [October 25, 2022, 2:16pm UTC](https://kopia.discourse.group/t/i-do-not-want-to-back-up-cache-directories-how-can-i-exclude-them/1500/3 "2022-10-25T14:16:55Z")

</div>

CACHEDIR.TAG exists within a kopia folder, inside the ~/Library/Caches directory.

Why would you not exclude the whole caches folder?

> Your `kopia policy...` command can not work obviously. You exclude `.cache` and the directory name on macOS is `Caches` .

I don’t understand why my kopia policy command so “obviously” can not work. Did you make that comment because you only read part of the command I wrote, or did I actually misunderstand something?

---

<div class="post-metadata">

**Author:** ![manfredlotz](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/manfredlotz/32/175_2.png) [@manfredlotz](https://kopia.discourse.group/u/manfredlotz)\
**Post date:** [October 25, 2022, 5:25pm UTC](https://kopia.discourse.group/t/i-do-not-want-to-back-up-cache-directories-how-can-i-exclude-them/1500/4 "2022-10-25T17:25:48Z")

</div>

> [@Angler](#):
>
> > Your `kopia policy...` command can not work obviously. You exclude `.cache` and the directory name on macOS is `Caches` .
> 
> I don’t understand why my kopia policy command so “obviously” can not work. Did you make that comment because you only read part of the command I wrote, or did I actually misunderstand something?

Yes, I was too quick here. Nevertheless, I think in order to make this work you have to indicate that the pattern is a directory.

So either `--add-ignore /Caches/` or `--add-ignore Caches/` should work. Not sure which one.

---

<div class="post-metadata">

**Author:** ![manfredlotz](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/manfredlotz/32/175_2.png) [@manfredlotz](https://kopia.discourse.group/u/manfredlotz)\
**Post date:** [October 25, 2022, 5:27pm UTC](https://kopia.discourse.group/t/i-do-not-want-to-back-up-cache-directories-how-can-i-exclude-them/1500/5 "2022-10-25T17:27:58Z")

</div>

> [@Angler](#):
>
> Why would you not exclude the whole caches folder?

Just because I like to be cautious and secondy it could make things more comfortable if after a restore a cache directory doesn’t need to be rebuilt.

---

<div class="post-metadata">

**Author:** ![budy](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/budy/32/38_2.png) [@budy](https://kopia.discourse.group/u/budy)\
**Post date:** [October 26, 2022, 8:28am UTC](https://kopia.discourse.group/t/i-do-not-want-to-back-up-cache-directories-how-can-i-exclude-them/1500/6 "2022-10-26T08:28:56Z")

</div>

Well… should you ever be in need to restore your account on macOS, the contents of the cache folders will only be of limited use. There are al lot of objects with guuids which would change on a new install anyway.

~/Library/Caches is just a waste to backup in a long term scenario. Save the space and maintain an actual backup of your home folder using something like CCC on macOS. As much as I love Kopia, there’s no faster way to restore your account, than a cloned home folder.

As for the syntax, you will need to omit the leading / so if you wanted to exclude ~/Library/Caches you’d simply put Library/Caches in to the policy.

---

<div class="post-metadata">

**Author:** ![dimejo](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/dimejo/32/287_2.png) [@dimejo](https://kopia.discourse.group/u/dimejo)\
**Post date:** [October 28, 2022, 8:40am UTC](https://kopia.discourse.group/t/i-do-not-want-to-back-up-cache-directories-how-can-i-exclude-them/1500/7 "2022-10-28T08:40:36Z")

</div>

> [@manfredlotz](#):
>
> So either `--add-ignore /Caches/` or `--add-ignore Caches/` should work. Not sure which one.

The help text states that this needs to be **specified as relative to the directory they are in and not absolute**. Hence `/Caches/` shouldn’t work.
