--exclude-caches

how the --exclude-caches works?

From restic help backup:

excludes cache directories that are marked with a CACHEDIR.TAG file

This means restic will skip over any directory that contains a file with the name CACHEDIR.TAG, regardless of the file’s contents. Some software will create such a file in their cache directories specifically to indicate that the directory does not need to be backed up, but other software does not know about this practice. Therefore, you may still need to explicitly --exclude cache directories (like /var/cache on Linux).

2 Likes

Ah, that’s not exactly right, it needs to have the correct content: https://bford.info/cachedir/

3 Likes

Ah, THAT’S where it comes from! I was wondering how the heck the “CACHEDIR.TAG” stuff works. Thanks for the link.

1 Like

Oh, hm. I wasn’t aware that this isn’t known widely…maybe we can find a good spot to add a link to the docs…

It is important respect the specs, otherwise:

uploaded intermediate index 10d1bf4a
uploaded intermediate index 3e51b5b9
uploaded intermediate index 0b75cb08
invalid (too short) signature in exclusion tagfile "/usr/home/xxxxx/www/wp-content/uploads/snapshots/CACHEDIR.TAG"
invalid (too short) signature in exclusion tagfile "/usr/home/xxxxx/www/wp-content/uploads/snapshots/_backup/CACHEDIR.TAG"
invalid (too short) signature in exclusion tagfile "/usr/home/xxxxx/www/wp-content/uploads/snapshots/_locks/CACHEDIR.TAG"
invalid (too short) signature in exclusion tagfile "/usr/home/xxxxx/www/wp-content/uploads/snapshots/_logs/CACHEDIR.TAG"
invalid (too short) signature in exclusion tagfile "/usr/home/xxxxx/www/wp-content/uploads/snapshots/_logs/_sessions/CACHEDIR.TAG"
invalid (too short) signature in exclusion tagfile "/usr/home/xxxxx/www/wp-content/uploads/snapshots/_restore/CACHEDIR.TAG"
uploaded intermediate index 1a7d7e3e
uploaded intermediate index 7e29b1b8
uploaded intermediate index e43bd144

Those files are empty:

# cat /usr/home/xxxxxx/www/wp-content/uploads/snapshots/CACHEDIR.TAG
#

There is the workaround of --exclude-if-present CACHEDIR.TAG, but that may be a bit too risky…

Current restic help displays

–exclude-caches excludes cache directories that are marked with a CACHEDIR.TAG file. See Cache Directory Tagging Specification – Bryan Ford's Home Page for the Cache Directory Tagging Standard

Shouldn’t it display
excludes cache directories contents that are marked with a CACHEDIR.TAG file. See Cache Directory Tagging Specification – Bryan Ford's Home Page for the Cache Directory Tagging Standard

In the backup I have the folder and the file “CACHEDIR.TAG” but not no any other content, as desired.
Or am I doing something wrong? --exclude-caches is set of course.

I like that way restic is handling it, so you see in the backup why there is no content instead of the whole folder completly missing. If this is the intended behaviour, I’ll create a pull request to update the relevant docs and cmd help.