Skip to content

fix restic unlock success detection#284

Merged
itzg merged 1 commit into
itzg:masterfrom
Gardelll:master
Mar 19, 2026
Merged

fix restic unlock success detection#284
itzg merged 1 commit into
itzg:masterfrom
Gardelll:master

Conversation

@Gardelll
Copy link
Copy Markdown
Contributor

Summary

  • rely on restic unlock exit status instead of matching success in stdout
  • log restic unlock output when present
  • avoid false unlock failures in scheduled restic backups

Context

In a docker-mc-backup container using BACKUP_METHOD=restic with an S3-compatible RESTIC_REPOSITORY, the scheduled backup path repeatedly logged:

INFO Repository already initialized
INFO Checking for stale locks
WARN Confirmed stale lock on repo, unlocking...
ERROR Unable to unlock the repo. Is there another process running?

However, in the same container:

  • backup now succeeded
  • restic list locks returned no output and exited 0 immediately after the scheduled failure
  • restic unlock -v returned no output and exited 0 immediately after the scheduled failure

The existing logic requires restic unlock stdout to contain success, which can misclassify a successful unlock when the command exits 0 without printing that string.

@Gardelll

This comment was marked as outdated.

@Gardelll
Copy link
Copy Markdown
Contributor Author

Quick test update from my side.

I built this branch into a custom image and rolled it out to a test docker-mc-backup sidecar using BACKUP_METHOD=restic with an S3-compatible RESTIC_REPOSITORY.

What I checked in the test container:

  • the patched /opt/backup-loop.sh is present
  • backup now works
  • the cron-equivalent path also works when run as:
    • export ONE_SHOT=true; /opt/backup-loop.sh

That cron-equivalent run went through:

  • Repository already initialized
  • Checking for stale locks
  • Checking repo integrity
  • backup completed successfully
  • a new snapshot was saved
  • prune completed successfully

In this test run I did not hit the previous pattern:

WARN Confirmed stale lock on repo, unlocking...
ERROR Unable to unlock the repo. Is there another process running?

@Gardelll Gardelll mentioned this pull request Mar 19, 2026
@Gardelll Gardelll marked this pull request as ready for review March 19, 2026 18:15
Copy link
Copy Markdown
Owner

@itzg itzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Ready for me to merge this?

@itzg itzg linked an issue Mar 19, 2026 that may be closed by this pull request
@Gardelll
Copy link
Copy Markdown
Contributor Author

Thanks! Ready for me to merge this?

Yes, that works fine for me.

@itzg itzg merged commit 5b35545 into itzg:master Mar 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restic Unlock Error

2 participants