Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlocking stale locks will pass CLI flags to restic unlock #402

Open
scy opened this issue Sep 16, 2024 · 0 comments
Open

Unlocking stale locks will pass CLI flags to restic unlock #402

scy opened this issue Sep 16, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@scy
Copy link
Contributor

scy commented Sep 16, 2024

I have this repository that's been unmonitored for a few months. I've noticed that forget is apparently not running, so I've tried to run it manually, adding -n to first have a look at what it would be doing:

$ sudo resticprofile local.forget -n
2024/09/16 16:34:29 using configuration file: /etc/restic/profiles.yaml
2024/09/16 16:34:29 profile 'local': initializing repository (if not existing)
2024/09/16 16:34:29 profile 'local': starting 'forget'
repository 2962f6e8 opened (version 2, compression level auto)
found 1 old cache directories in /root/.cache/restic, run `restic cache --cleanup` to remove them
repo already locked, waiting up to 0s for the lock
unable to create lock in backend: repository is already locked by PID 967 on spec by root (UID 0, GID 0)
lock was created at 2024-06-02 15:31:06 (2545h3m23.272568633s ago)
storage ID 9b796ee8
the `unlock` command can be used to remove stale locks
2024/09/16 16:34:29 restic: possible stale lock detected (lock age 2545h3m23.272s >= 1h0m0s). Set `force-inactive-lock` to `true` to enable automatic unlocking of stale locks.
2024/09/16 16:34:29 forget on profile 'local': exit status 11

Oh, okay, so the issue seems to be that there's a stale lock that's three months old.

I didn't have force-inactive-lock in my config beforehand, but I've added it now. Trying again:

$ sudo resticprofile local.forget -n
2024/09/16 16:50:42 using configuration file: /etc/restic/profiles.yaml
2024/09/16 16:50:42 profile 'local': initializing repository (if not existing)
2024/09/16 16:50:42 profile 'local': starting 'forget'
repository 2962f6e8 opened (version 2, compression level auto)
found 1 old cache directories in /root/.cache/restic, run `restic cache --cleanup` to remove them
repo already locked, waiting up to 0s for the lock
unable to create lock in backend: repository is already locked by PID 967 on spec by root (UID 0, GID 0)
lock was created at 2024-06-02 15:31:06 (2545h19m36.35688122s ago)
storage ID 9b796ee8
the `unlock` command can be used to remove stale locks
2024/09/16 16:50:43 restic: possible stale lock detected (lock age 2545h19m36.356s >= 2h0m0s). Trying to unlock.
2024/09/16 16:50:43 profile 'local': unlock stale locks
unknown shorthand flag: 'n' in -n
2024/09/16 16:50:43 failed removing stale lock. Cause: unlock on profile 'local': exit status 1
2024/09/16 16:50:43 forget on profile 'local': exit status 11

It detected the stale lock and tried to remove it. The error message unknown shorthand flag: 'n' in -n looks as if resticprofile is passing the -n I've specified on the command line to the restic unlock command, which of course doesn't know what to do with it.

In my opinion, when restic unlock is being called from resticprofile as a result of force-inactive-lock, resticprofile should not pass any user-specified command line arguments. When calling it manually though (e.g. resticprofile local.unlock), command line arguments should be forwarded as usual.

@creativeprojects creativeprojects self-assigned this Sep 19, 2024
@creativeprojects creativeprojects added the bug Something isn't working label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants