Restic on Synology - cache dir

I’m running restic 0.9.6 on my Synology DS418, backup up the content to B2.
I have set the cache-directory using the $RESTIC_CACHE_DIR variable. Running restic cache displays the correct location when running it under my user and as root. But when running sudo restic cache, the path is displayed as /root/.cache/restic.
It’s is problematic on the Synology, as /root/ is placed on the small and un-expandable system partition /dev/md0.
Any ideas on how to get sudo to read and use the variable?

I have tried running the restic commands with --cache-dir, but restic check --with-cache --cache-dir /volume2/backup/restic/cache fails.

I cannot create an unprivileged user, as the setcap command is not available.

sudo -E should bring the caller’s environment variables with them. You could also create a symlink from /root/.cache/restic to your preferred location.

I’ll try that. I figured out why the command failed, my script gave me a better error this time. The past time it had just said the process has been killed.
But it turns out, it runs out of memory. I tried cleaning up the services a bit and got a successful run. It only got 2GB, considering adding more.

Hello, how did you install Restic on Synology NAS? Full Restic or just container via Docker?
I am trying to run Restic on Synology NAS as well, but still cannot find any solution.
Thank you