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

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

macOS, KopiaUI v0.12.1

My global policy

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

I tried this recommendation, 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,

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?

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

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).

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?

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.

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.

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.

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.

1 Like