Restic prune fails to remove lock

I recently noticed that my automated backups did not work anymore, due to an unremoved lock on the repository. I am backing up with the sftp backend onto a raspberry pi. The problem seems to appear when running restic forget:
restic forget --keep-daily 7 --keep-weekly 5 --keep-monthly 12 --keep-yearly 10 --prune
I get loads of error messages like this in the stdout:

Nov 19 02:42:43 gaspodelaptop .backup.sh[10059]: load all snapshots
Nov 19 02:42:43 gaspodelaptop .backup.sh[10059]: find data that is still in use for 18 snapshots
Nov 19 03:05:45 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 552.330144ms: file does not exist
Nov 19 03:05:45 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 1.080381816s: file does not exist
Nov 19 03:05:46 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 1.31013006s: file does not exist
Nov 19 03:05:48 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 1.582392691s: file does not exist
Nov 19 03:05:49 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 2.340488664s: file does not exist
Nov 19 03:05:52 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 4.506218855s: file does not exist
Nov 19 03:05:56 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 3.221479586s: file does not exist
Nov 19 03:05:59 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 5.608623477s: file does not exist
Nov 19 03:06:05 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 7.649837917s: file does not exist
Nov 19 03:06:13 gaspodelaptop .backup.sh[10059]: Remove(<lock/6a7949ff5f>) returned error, retrying after 15.394871241s: file does not exist
Nov 19 03:06:28 gaspodelaptop .backup.sh[10059]: unable to refresh lock: file does not exist

I ran restic unlock and the next backup started and went through, but left the repo locked again. I did not recently change anything on the pi or the system that is backed up. It might be a connection issue since I am backing up over wifi, but it did not happen at all in the last few months. I will keep an eye on it.

I started the backup manually (but using the same systemd service I use for automated backup) just now to check if the lockfile that could not be removed actually exists in the repo, but this backup went through without leaving the repo locked.
I am using restic 0.9.5 on arch linux.

Hi @Gasp0de and welcome to the restic community forum! :slight_smile:

So when doing a backup manually, you saw a lock file in the locks directory?
And once the backup finishes, the lock gets removed?

So the user you are using for the sftp backend has the appropriate rights on the backend system to create all the needed files etc. This includes deleting files and folders - as forget and prune would.