[Feature] Support Repository lock while running before_backup actions #812
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#812
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'd like to do and why
It would be great to have the option to lock the Borg Repo before running commands specified in before_backup
Why:
Maybe it is as easy as prepend "borgmatic borg with-lock :: " to each command specific in before_backup but i'm not really sure about it.
And would prefer it to be an option in the borgmatic config file
Other notes / implementation ideas
No response
Thanks for taking the time to file this and outline the rationale! Can you give me an example though of some of these
before_backup
tasks you have in mind so I can better understand your second point—that users should not be able to mount the repo by accident while such a task is running? For instance, for somebefore_backup
tasks I can imagine (like dumping a database or mounting a filesystem), you wouldn't necessarily want to lock the repo because it's not actually being touched by the preparation tasks.And what do you imagine running at the same time that this lock would protect against? Someone running a
borg
command manually? Or another instance ofborgmatic
already running, perhaps started automatically from cron or systemd?Does the need for the lock encompass any
after_backup
tasks as well? Or would that be a separate locking need? And what about other action command hooks likebefore_prune
, etc.?If you mean that a user would manually prepend that to each command, I generally don't recommend invoking borgmatic from borgmatic, as that opens up the possibility of recursion problems. But if you meant that borgmatic would implicitly prepend each
before_backup
command withborg with-lock ...
, that might work. The big downside I could see though is that the lock would unlock between each command (and between the final command and the actualborg create
), thereby creating an opportunity for another process to slip in and steal the lock and do something unexpected.Depending on the use case, it might make more sense to take out a lock (maybe even a borgmatic-specific lock) before all
before_backup
commands and then unlock it after they're all done or even maybe afterborg create
completes.Closing this for now due to inactivity, but I'd be happy to revisit this if you'd like to discuss further! Thanks.