-
Notifications
You must be signed in to change notification settings - Fork 29
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
Added resticprofile flags --no-lock & --lock-wait #33
Added resticprofile flags --no-lock & --lock-wait #33
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Codecov Report
@@ Coverage Diff @@
## master #33 +/- ##
==========================================
+ Coverage 53.48% 54.83% +1.34%
==========================================
Files 49 50 +1
Lines 3255 3478 +223
==========================================
+ Hits 1741 1907 +166
- Misses 1359 1394 +35
- Partials 155 177 +22
Continue to review full report at Codecov.
|
Yeah I don't particularly need it the way I use restic. But if you need it on your workflow, please go ahead 😃 |
Actually I had this issue recently, although this PR wouldn't have solved it: I have 2 central backup machines where all my servers push new file every night. One of the server had a big upgrade and pushed a lot more than usual, and then all the other night backup failed. I think the "wait for lock" option could also be checking the restic lock regularly and wait until it's free to go. If possible. Maybe. |
Yes I have this as a separate pre-run script to check the restic lock (and wait for it and/or remove stale locks). Sorry for the delay, try to finish this PR next week and will then also check how to integrate restic lock handling. |
Excellent 👍🏻
Don't worry, I've also been busy on other things lately 😄 |
This PR is updated to contain missing ideas like schedule config and restic lock handling (stale and lock wait). I still need to test and review the changes myself and rewrite output capturing since I missed the latest changes in master :). |
"--lock-wait" also waits on non-stale restic remote locks Stale locks are unlocked when "force-inactive-locks" is true Uses global section to configure the behaviour (can also be disabled)
3f90b19
to
fb2d0c6
Compare
Unit tests have been written and code was cleaned-up. |
Had several profiles scheduled hourly on 2 servers pointing to the same repo, resulting in several 100 backups over the past days. There was lots of log output like this:
... but not a single failure, all scheduled jobs succeeded. @creativeprojects : I'm removing the WIP flag as I think it is ready for review now. |
Excellent! I'll study it in the next few days 👍🏻 Thanks |
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
The message I'm using for the local lock is completely different than the restic one. I never noticed that before and it does look stupid 😆 (I might want to change that at some point.) Anyway, I tried a few very close backup overnight and it worked perfectly fine, so I'm merging the PR. Thank you very much, it works nicely and it's going to be very useful 👍🏻 |
Coming late after the party. Wouldn't it be useful to have options such as I prefer having global In the same way wouldn't it be nice to have an |
Hi @renard, it looks like you are referring to restic |
Ah yes that is it. We should be careful about that: the Looks like other variants are not taken in account ie. you cannot use Some implementations allow This is still unclear to me. However specifying EDIT: looks like the syntax changed between yaml 1.1 and 1.2: https://yaml.org/spec/1.1/#id864510 |
This draft PR adds 2 resticprofile flags (and schedule & global configs) to control locking behaviour (profile locks & restic remote locks)
@creativeprojects, let me know whether this is acceptable. If so I'll test and document it.
Currently I'm not using the built-in locking as I'm missing these 2 features.
Added flags:
--no-lock
: Ignores any defined locks.Motivation: Not all tasks really need a lock, e.g. I usually run
resiticprofile --name $PROFILE_NAME unlock
as pre-run to ensure stale locks are removed. With profile locks this only works when locks can be ignored.--lock-wait
: Wait up to the specified duration to acquire a lock before failing.Motivation: When triggering operations that should use a lock, one can't always avoid concurrency (e.g. in schedules that may take longer than expected). However it should be configurable whether concurrency will immediately cause a failure or only when some time passed and it didn't resolve.
Added schedule config:
schedule-lock-mode
(default | fail | ignore): Toggles wether to set--lock-wait
(default) or--no-lock
(ignore) flags.schedule-lock-wait
: Toggles whetherdefault
sets--lock-wait
to a duration.Added global config:
restic-lock-retry-after
: Sets a delay for retrying restic commands that fail to acquire a repository lock. 0 disables handling remote lock failures.restic-stale-lock-age
: Sets a lock age for detecting stale locks. Stale locks are not waited upon butrestic unlock
is tried once (whenforce-inactive-lock
is also set in the profile). 0 disables stale lock handling.Status