Exclude patterns for caches

I just wrote the following in my excludes file to catch directories with cache (and variants) in their name.


# Match one or more directories: **/
# To exclude only directories called foo:  foo/
# Matches are on complete path segments: foo doesn't match foobar
# https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files
# Patterns:  https://pkg.go.dev/path/filepath#Match
# Additionally;
# - A trailing / is ignored, a leading / anchors the pattern at the root directory.
# - Regular wildcards cannot be used to match over the directory separator /
#   e.g. b*ash matches /bin/bash but does not match /bin/ash.
# - The special wildcard ** can be used to match arbitrary sub-directories

# Caches

# Others that don't match the above

# ==============================================================================
# Comments only below here

# Application Cache/
# ApplicationManifestsCache/
# AssetCache/
# CacheStorage/
# component_crx_cache/
# Code Cache/
# DawnCache/
# extensions_crx_cache/
# GraphiteDawnCache/
# GrShaderCache/
# GPUCache/
# google-chrome/*/Application Cache/
# # Microsoft caches (may contain FIFO files)
# CryptnetUrlCache/
# INetCache/
# media_cache/
# notionAssetCache*/
# repository-cache/
# ScriptCache/
# Shader Cache/
# ShaderCache
# # Electron apps seem to do this
# .config/*/GPUCache/
# .config/*/ShaderCache/
# # Microsoft VS Code follows different standards
# .config/Code/CachedData/
# .config/Code/CachedExtensions/
# #.config/Code/logs/
# # Sass caches
# tmp/sass-cache/
# .sass-cache/

# Deleted files  (keeping these as the data may be otherwise inaccessible)
# .Trash/
# Trash/

# Keep this as it seems to only be kilobytes
# Windows volume information
# System Volume Information/
1 Like

Iā€™m curious how much this actually saves :thinking: I never exclude stuff like this, the only thing I exclude are dirs with the CACHEDIR.TAG file in them and the list of files/folders from mdutil in macOS. This might be something to test on a friday night :slight_smile:

TIL (I bet if I search my shell history I used it before but forgot about it) about mdutil

I have found that using

mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'"

as very valuable as well :point_up: This way I get the same excludes as Apple chooses for their Time Machine backup.

1 Like

Thanks for sharing. This is a nice tip but not something to rely on exclusively. It does not include obvious items like ~/Library/Caches or ~/Library/Logs which are excluded by Time Machine.

And I can confirm that ~/Library/Caches is excluded:

$ tmutil isexcluded /Users/kptsky/Library/Caches/
[Excluded]    /System/Volumes/Data/Users/kptsky/Library/Caches

which means that mdifind only reports some subset of all TM exclusions - it looks like mostly what 3rd party apps set by using com_apple_backup_excludeItem extended attribute.

Still looking for how to find ALL Time Machine exclusions.

1 Like

Interesting results! Thanks for sharing this ā€“ I have to revisit my macOS backups :smiley:

only place where you can find sort of full exclusion list is TM backup itself

you have to use terminal (as Finder creates snapshots view) and go to /Volumes/YourTMdisk/SomeDate-previous which points to your last TM backup.

There you will find:


Copy it out and use whatever plist editor you like - I use BBEdit.

This file contains few sections. The <key>standardExclusionPaths</key> I think contains patterns as here you will find /Library/Caches. So I would from this section add all as **/Library/Caches to restic exclusions list as you want to exclude all items like:


~/Library/Caches is general cache used by normal apps and system.

In ~/Library/Containers you have all isolated environments of all sandboxed apps which include all Library structure but separated by app.

The same with Library/Logs and other elements from standardExclusionPaths. I add all of them.

Then other sections contain explicit exclusions which should be easy to add as they are (minus /System/Volumes/Data from path).

And if you find any better way to get all TM exclusions please share:)

1 Like

Thanks for sharing this with us :slight_smile: