Restic does not use Temporary Directory specified in environment variable

restic version
restic 0.16.4 compiled with go1.21.6 on windows/amd64

I tried to set temporary directory using TEMP, TMP and TMPDIR environment variables but temporary packfiles during backup and prune are created in default folders.

The temporary folder, which I want to use, does exist.

Running restic with nssm as Local Account, it creates temp files in C:\Windows\SystemTemp and running it with my user account, it creates temp files in %LOCALAPPDATA%\Temp. I verified this using process monitor.

I do this on MacOS with the following command and restic switch, often when I’m dealing with a failing drive and don’t want to tax it further than necessary.

export TMPDIR=/path/to/tmp
restic --cache-dir /path/to/cache ...

I think what you’re looking for in Windows is:

SETX TMP R:\path\to\tmp
SETX TEMP R:\path\to\temp
restic --cache-dir R:\path\to\cache

On Windows, restic checks both TMP and TEMP, see Manual — restic 0.16.5-dev documentation . (I’ve linked to the “latest” documentation, as that section is incorrect in the “stable” version documentation).

My guess would be that the environment variable somehow wasn’t properly passed on to restic.

1 Like

I think so too. I tried running restic directly from command line and it uses the specified temporary folder.

But using backrest, I cannot set the environment variable.

If someone encounters the same issue, here is a possible fix : Cannot set temp variable · Issue #403 · garethgeorge/backrest · GitHub