[restic 0.18.0 compiled with go1.24.1 on linux/amd64]
I’m fairly confused about how the --cache-dir
option works.
I currently have a simple wrapper script which sets environment variable (such as RESTIC_REPOSITORY
, RESTIC_PASSWORD
, AWS_*
, RESTIC_COMPRESSION
, RESTIC_PACK_SIZE
, etc)
It then ensures a directory (currently called ‘/export/restic/cache’) exists, and passes that to restic as
/usr/bin/restic --cache-dir="${CACHE_DIR}" --cleanup-cache "@"
Despite consistently setting ‘–cache-dir=’, I have cache files scattered between
- /root/.cache/restic
- /var/cache/restic
- /export/restic/cache
I’ve also tried setting the following
export RESTIC_CACHE_DIR="${CACHE_DIR}"
export TMP="${CACHE_DIR}"
export TMPDIR="${CACHE_DIR}"
(originally because restic check / prune overflowed /tmp and I needed these to force it to use another directory)
It feels like restic backup
as root ignores both $RESTIC_CACHE_DIR
and --cache-dir
and just goes to /var/cache/restic
.
Other commands like restic prune
ignore cache-dir entirely and write everything to /tmp or $TMP
or $TMPDIR
.
What is the correct way to use $CACHE_DIR
for everything?
Thanks