Restic including cache by default - good or bad?

Hey all,

Noticed that Restic backs up its own cache directories by default. Is there any reason this is done intentionally? Or is this a case of “your backup software should not be choosing by itself what gets backed up”? Or is this just happening because the cache’s I’m backing up are on an LVM snapshot instead of a live filesystem? :slight_smile:

Unless instructed otherwise, restic will save everything passed as argument to backup. The only exception is the cache dir that is in use during the run of restic backup: It is excluded automatically. The problem is that restic doesn’t know that there’s a second copy of the cache in the directory you’re saving (the lvm snapshot), but you can tell it to ignore all caches marked as such (via CACHEDIR.tag) with --exclude-caches. That’d be my recommendation.

1 Like

Good to know, thanks. Is there a performance hit on the backup operation by using --exclude-caches? Or is it pretty easy to know if the folder is a restic cache.

Every directory which has a file named CACHEDIR.TAG in it is excluded from backups. If anything I’d expect this to boost the performance as restic doesn’t need to enter any subdirectories to scan and backup.

1 Like

The performance impact is one additional stat syscall per directory, to find out if there’s a CACHEDIR.TAG in it. That’s about it, should be negligible all in all.

1 Like

Awesome, thanks for clarifying :slight_smile: Is the CACHEDIR.TAG a recursive effect, or do I have to touch this file in each subdirectory also? :slight_smile:

Quoting from the spec:

the entire contents of that directory, including any and all subdirectories underneath it

Didn’t even know that was a spec - thanks for that :slight_smile: