Backups: Automatically recover from "Failed to create/acquire the lock /root/.cache/borg/.../lock.exclusive" after forced reboot

Problem Description
I had to force shut-down my FreedomBox and after turning it on again Borg backups wouldn’t work. System logs contained the following error message at the end of a stack trace:
Failed to create/acquire the lock /root/.cache/borg/e1669c08151d670b6d1fdd2204f22b9b1cb69cd9b09bd4b420e249b6f0477c08/lock.exclusive
It seemed that the shut down happened in the middle of a backup process. I had to manually break the locks [1] in all repositories in order to get the backups working again.
Since it is likely that this will happen again in the future, are there any option to have the “Backups” application to auto-recover from this situation?

[1] borg with-lock — Borg - Deduplicating Archiver 1.1.16 documentation

Steps to Reproduce

  1. Start a backup process.
  2. Pull the power cord of the FreedomBox instance (or force shutdown if virtualised)
  3. That backup profile won’t be able to run until the lock is broken.

Expected Results
Backups work without any manual intervention after restarting the system.

Actual results
Borg backup locks stay inconsistent and the following error message is risen after every backup attempt:
Failed to create/acquire the lock /root/.cache/borg/e1669c08151d670b6d1fdd2204f22b9b1cb69cd9b09bd4b420e249b6f0477c08/lock.exclusive


  • FreedomBox version: 21.10
  • Hardware: libvirt
  • How did you install FreedomBox?: clean Debian installation