Cannot 'forget --prune' due to lock I can't remove

I have run the following to remove a file from a repository:

sudo restic -p /home/tomc/Dropbox/ssap -r /media/tomc/SSD-WD01-backup/galp5-popos-SSD/bk-hid3a rewrite --exclude /home/tomc/.recoll

Following documentation at Working with repositories — restic 0.15.2 documentation, I am now trying to run the follow ‘forget --prune’ command, but running into a problem I don’t know how to handle:

tomc@sys76-pop-os:~$ sudo restic -p /home/tomc/Dropbox/ssap forget --prune --keep-monthly 3 --keep-weekly 4 --keep-daily 6 --keep-hourly 6 -r /media/tomc/SSD-WD01-backup/galp5-popos-SSD/bk-hid3a
repository 057abcef opened (version 2, compression level auto)
found 6 old cache directories in /root/.cache/restic, run `restic cache --cleanup` to remove them
Fatal: unable to create lock in backend: repository is already locked exclusively by PID 132152 on sys76-pop-os by tomc (UID 1000, GID 1000)
lock was created at 2023-05-29 16:11:12 (31m33.835309807s ago)
storage ID 7d385500
tomc@sys76-pop-os:~$ ps -p 132152
    PID TTY          TIME CMD
tomc@sys76-pop-os:~$ kill -9 132152
bash: kill: (132152) - No such process

Rerunning the ‘forget --prune’ command simply loops through this again.

What’s happening…and how do I fix it this?

Could you try restic unlock? If the pid given is already gone, might be a stale lock.

1 Like

You can try restic unlock:

restic -p /home/tomc/Dropbox/ssap -r /media/tomc/SSD-WD01-backup/galp5-popos-SSD/bk-hid3a unlock

1 Like

Thank you, and gurkan as well. This was not something I knew about and it worked perfectly.

Arghh, the hint to use the unlock command was missing again since restic 0.15.1 lock: fix missing hint to unlock command if repository is locked by MichaelEischer · Pull Request #4356 · restic/restic · GitHub

1 Like