Borg with-lock? How to use.? #79
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#79
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?
Hello, I use borgmatic because it simplifies stuff and allows me to discover config option easily
but how to activate borg with-lock to prevent errors?
You should still be able to run the Borg
with-lock
sub-command manually outside of borgmatic. Could you tell me a little bit more about your use case / how you're wanting to usewith-lock
with borgmatic? Thanks!Also note that borgmatic has support for "hooks" that will execute your custom commands before or after a backup. However, right now they don't run within Borg's
with-lock
. Maybe that would be a good enhancement to make? Finding out about your use case will help me determine whether that'll actually solve your problem.I have to make a tar archive of my borg repo and send it through ftp so that would come in handy to avoid corruption I guess?
Got it. Is that the sort of thing you'd want to trigger after a borgmatic backup completes? For reference, here's the current documentation for borgmatic hooks:
So does
after_backup
sounds like it would work for your needs if the hook command usesborg with-lock
?Hey, sorry I'm a real beginner, I'm not even sure about the use of borg with-lock but Thomas Waldmann said to use it in my case to prevent corruption
Actually I made a script like this:
Do you suggest me to remove "launch borgmatic" from the script and add the script in the hooks part? and just run borgmatic regularly
but the with-lock part must be added into borgmatic's source right?
Okay, one last question (hopefully): Can you clarify what part you'd like to run within the protection of the
with-lock
? Is it actually making the backup and tarring the repo and sending it through FTP? Or is it just tarring the repo and sending it through FTP? Thanks.I really don't know, it's just for added security. That's what borg author told me to do.
I have nothing that conflicts with the repo, no operation is ran during the backup IN THEORY. At first sight I don't need it but why does it exist and why did the author advise to use it then?
Not sure what the Borg author had in mind, but my guess is that the operation of tarring up the Borg repo could result in an inconsistent/broken tarball if another process happens to be writing to the Borg repository at the same time.
Given what you've said so far, and looking at the contents of your script, there shouldn't be another process writing to the Borg repository at the same time as the
tar
operation. But if you wanted to protect against that just to be safe, here's what I'd recommend. You can implement one of the two following options:tar
command in your script to be wrapped with aborg with-lock
invocation, referencing the desired repository. That should work with no changes to borgmatic. I'm saying that based on my understanding that, anytime borgmatic invokes Borg, Borg takes out its own repository lock.tar
invocation and the "send through ftp" invocation into borgmatic's hooks configuration as anafter_backup
hook. There, you'd still have to wrap thetar
invocation withborg with-lock
. Given that you'd be callingwith-lock
yourself, that wouldn't require any borgmatic changes either.Which one you do depends on whether you want to keep your own script around to do the tarring and FTPing, or whether you'd prefer borgmatic to handle that for you from a common configuration file.
Let me know if that sounds like either of those will work for you.
Ok so, I just discovered how the command is used thanks to you... I think borgbackup docs are not so obvious lol
so I can use it like that:
both options are the same, right? it's just that if I choose option 2 I need to remake my script
Yup, basically the same thing in either case. Really a matter of preference.
ok then I understand better, borgmatic will automatically lock the repo as it's calling borg (and I suppose it's a default setting?)
If I lock the repo when doing tar, it will prevent me from doing anything to the repo manually while the script is running.
So I guess the solution is found and sorry, in the end it was not really related to borgmatic (well I learned about the "after_backup" hook though)
Thank you :P
That's all correct. No need to apologize.. Always happy to help!