I just wrote the following in my excludes file to catch directories with cache (and variants) in their name.
HTH!
# 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
[cC]ache/
[cC]ache[sd]/
.[cC]ache/
.[cC]ache[sd]/
[cC]ache[^a-z]*/
[cC]ache[sd][^a-z]*/
*[^A-Z]Cache/
*[^A-Z]Cache[sd]/
*[^a-z]cache/
*[^a-z]cache[sd]/
*[^a-z]cache[^a-z]*/
*[^a-z]cache[sd][^a-z]*/
*[^A-Z]Cache[^a-z]*/
*[^A-Z]Cache[sd][^a-z]*/
*[^A-Z]CACHE[^a-z]*/
*[^A-Z]CACHE[SD][^a-z]*/
# Others that don't match the above
__pycache__/
GPUCache/
LRUCache/
# ==============================================================================
# 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/
Iām curious how much this actually saves 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
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:
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.
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:
.exclusions.plist
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: