restic: unable to create lock in backend: repository is already locked
Output of restic version
restic 0.8.0
compiled with go1.9 on linux/amd64
How did you run restic exactly?
restic -r /path/to/repository/external/drive backup "/path/to/source"
# crash after errors
restic -r /path/to/repository/external/drive backup "/path/to/source"
# success
restic -r /path/to/repository/external/drive check
# unable to create lock
restic -r /path/to/repository/external/drive check --no-lock
# Fatal: repository contains errors
What backend/server/service did you use to store the repository?
local to an external usb drive
Expected behavior
Restic to have error handling and correct previous backup.
After new successfully backup, no message of “unable to create lock in backend: repository is already locked by PID…”
A way to repair errors output by check --no-lock
Actual behavior
- “unable to create lock in backend: repository is already locked by PID 11327”
- “Fatal: repository contains errors”
Steps to reproduce the behavior
I ran a backup with:
restic -r /path/to/repository/external/drive backup "/path/to/source"
The backup failed (external drive seemed to be disconnected), so I ran the same command again, then it finished without errors. Now when I check the repository I get: “unable to create lock in backend: repository is already locked by PID 11327” There is no PID 11327 according to ps aux | grep 11327
restic -r /path/to/repository/external/drive check
If running check --no-lock
there are some not referenced in any index
entries and Fatal: repository contains errors
restic -r /path/to/repository/external/drive check --no-lock
When I run
restic -r /path/to/repository/external/drive prune
restic -r /path/to/repository/external/drive rebuild-index
Both commands output “unable to create lock in backend: repository is already locked by PID 11327”
Do you have any idea what may have caused this?
Errors when first run backup?
Do you have an idea how to solve the issue?
No
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (6 by maintainers)
Commits related to this issue
- https://github.com/restic/restic/issues/1450 — committed to bananocraft/bananocraft-deploy by satoshinnakamoto 2 years ago
- https://github.com/restic/restic/issues/1450 — committed to bananocraft/bananocraft-deploy by satoshinnakamoto 2 years ago
prune
took care of remain “not referenced in any index” whencheck
. To sum up:Hi,
I didn’t know about
unlock
. After using it, I could run check, rebuild-index and prune. Maybe it is a good idea to have it in the doc. I still don’t know how to proceed with check errors. Should I forget the snapshot and run a backup again (150GB)?When I run
rebuild-index
I still get errors whencheck
Worked for me, however I have no idea how is it possible that a process locked that repo without unlocking it afterwards, because I didn’t interrupt restic or anything :
I am sure of that because my RAM issue (totally unrelated to restic of course) happened something like 7-9 hours after the previous successfull backup, so I have no doubt that no call to restic has been made in the meantime, no upgrade of the pacman package neither, no cronjob nor external drive being plugged-in…
Is that possible that when calling backup command, restic might lock, “forget to unlock”, and then try to lock again ? Which would explain how you can get a lonely lock without having interrupted restic beforehand.