Restic specific variable for cache directory

Hi there!

We have restic available on our shared HPC cluster as a module (lmod). We recently ran into an issue with the caching directory for some users, for a large backup in S3 (100TB+). We only offer 15GB of home space, so it’s not enough to store the restic cache files, but we do have other filesystems available with a lot of storage (like en ephemeral $SCRATCH filesystem which sounds perfect for this).

With module/lmod, it’s easy to define environment variables, however, restic is using $XDG_CACHE_HOME which is not restic-specifc, and potentially can run into conflict with other modules we have. I’ve nothing against XDG_CACHE_HOME, but would it be possible to have
a restic specific variable to override the cache dir, as it would be defined in command line by --cache-dir=/path ? something like RESTIC_CACHE_DIR maybe?

Reference link:


One option that doesn’t require changing restic would be to use a wrapper script which can run restic with a modified XDG_CACHE_HOME. This way your other processes would not be affected.

XDG_CACHE_HOME=/something/else exec restic "$@"

Thanks @cdhowie! Pragmatic solution indeed. Note that if we do a wrapper, we could also directly pass --cache-dir= to the command line. In practice, we would like to avoid a wrapper. Do you think if we do a PR for a cache-dir variable this could be considered for inclusion? Let me know. Thanks again for this great software.

I think it’s reasonable to add a restic-specific override. This should be about a 3-line change to this function:

Awesome! Thanks much @cdhowie!