Unable to cleanup old cache (restic 0.9.3)


#1

I saw this thread but I don’t know if my problem is the same.

I’ve been using restic for a couple of months now and never had this problem. Since I upgraded to v0.9.3 this message appears to me twice in different hosts: removing 2 old cache dirs from /home/usr/.cache/restic: permission denied (message can be different; I lost the original message). Then running restic with sudo actually clean up the cache dir without problem. When running with sudo: repository 75ed913a opened successfully, password is correct created new cache in /root/.cache/restic. It is strange because I don’t run any restic related task with the root user; just this one. With versions 0.9.2 and earlier I never had this “problem”.

I have the restic binary in the home dir in server for system backup and the permissions for the binary are root:usr. Laptop runs restic from /usr/bin. Server is Debian Stretch and Laptop Ubuntu 18.04. Permissions in restic cache dirs for both hosts are set to their respective user.


#2

The issue here is that the default cache directory is relative to the current system user’s home directory. It looks like there are files in ~/.cache/restic for which you don’t have write permissions. The problem with running sudo restic is that now restic uses /root/.cache/restic for the cache directory. You can explicitly set the cache directory with --cache-dir.

So, I’d run chown -R $USER ~/.cache/restic and then run restic cache --cleanup, in addition to removing /root/.cache/restic.


#3

Before reading this comment I ran the sudo restic snapshots --cleanup-cache and the old cache was removed. Then I deleted the /root/.cache/restic because I assumed it was created by old testing processes when I was trying out restic with the root user. Without the need of chown the permissions in restic cache dir are:

total 20
drwx------ 4 admin admin 4096 Oct 27 13:27 .
drwx------ 3 admin admin 4096 Sep  8 15:10 ..
drwx------ 5 admin admin 4096 Oct 27 13:27 75ed913ab10e5778865e408367a5b58f94685fbb4afe3ff2382bc085befc1aa1
drwx------ 5 admin admin 4096 Oct 27 05:00 83e6861b97e8debad2b4714eb810551973aaeeda5227bc179d5b54211600f7e5
-rw-r--r-- 1 admin admin   44 Sep  8 15:10 CACHEDIR.TAG

The running restic is alwyas done by admin user, so I did nothing. I waited two or three days so restic would ask me to cleanup cache again and running --cleanup-cache worked fine. I don’t know what was the “problem” but it’s no problem anymore. Thanks for taking the time to answer @fd0.