Give the ability to supply additional Borg options #427
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#427
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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'm trying to do and why
Borg has additional options like
--bypass-lock. This option is dangerous to use in general, i.e. using it to allow multiple producers to write to repository is a big bang. Don't do this. However, for read-only operations (e.g.info,list,mount, etc.), even during archive creation, it's totally fine (see also https://github.com/borgbackup/borg/issues/5261).The above is just an example, there are other useful options as well. But let's continue with the above one for the sake of example.
I need a way to invoke both
infoandlistexactly in that order for each repository using--bypass-lockoption as well. Currently, there are multiple issues at play here.First of all, if we use regular
borgmatic ... info ... list ..., thenborgmatic, that islistwill always be called beforeinfo, and hence, appear in the output before. I think this should be changed to follow the order on the command line as it matters (in the current case for presentation purposes, but in other cases might matter logically). As a side question here, when invoked asborg ... info ... list ..., I see that Borg processes these in one go. Is there any particular reason why Borgmatic splits those into two separate invocations? I'm asking because this also affects the order and is another way to fix the described issue.--bypass-lock. To support that, there should either be a way to supply those common Borg options for anyborgmaticcommand in general and/or at the very leastinfoandlistshould be added into theextra_borg_optionsdictionary (though the issue will still facilitate itself for any other/future commands not in the dictionary).infoandlistappear per repository is interleaved. This is good and expected as it's important to present information aggregated per repository. The only issue is still from the first point aboutlistcoming beforeinfo.Secondly, due to two issues described above, I tried to resort to the new
borgmatic ... borg ...command, here is my feedback on it:borg ...invocation thoroughly. As a result, it's not possible to run eitherborgmatic ... borg info ... list ...orborgmatic ... borg info ... borg list .... This immediately leads to impossibility to displayinfoandlistper repository interleaved. As invoking them separately will aggregate firstinfofor all repositories and thenlistfor all repositories. The only good part is that--bypass-lockoption is accepted though only afterinfoorlist, which is semantically not the right place for such common Borg options. I think parsing can be improved by introducing special delimiters which would allow both options in front of Borg commands and multiple Borg commands to appear in one invocation, e.g.borgmatic ... borg [borgmatic borg options] -- [common borg options] info ... --- [borgmatic borg options] -- [common borg options] list ... ---- borg [borgmatic borg options] -- [common borg options] create ... --- [borgmatic borg options] -- [common borg options] prune .... So--ends Borgmatic options, regular convention,---separates multiple Borg commands within oneborginvocation,----return back to Borgmatic, so it can either run Borgmatic command(s) or run new Borg command(s) again.Environment
borgmatic version:
1.5.15Borg version:
1.1.16Python version:
3.9.1For point 2 above, there are existing options that almost support that:
However that doesn't yet support
listorinfo. However it wouldn't be difficult to add that support!Also, borgmatic doesn't parse each
borgaction thoroughly. However it does at minimum need to parse out that Borg command. That's because borgmatic needs to pass the borgmatic--repositoryand--archiveto Borg in the right spot in the constructed command-line—or else Borg blows up.Since borgmatic 1.7.9, the order of actions given on the command-line is the order they run in.
Looks like
--bypass-lockis gone in Borg 2.Hi, I would like to try and work on this issue!!
Great! I think this should just be a question of expanding the existing
extra_borg_optionsto support additional Borg subcommands, but please let me know if you have any questions along the way. And I'd be happy to brainstorm the approach if you want to do that ahead of a PR.Hello there
What are the most essential subcommands that need to be added? Or I'm free to decide which can be ported
Since this is 4 years old and while checking the PR that linked this issue, it seems the most essential borg commands have been ported\
My off-the-cuff answer is "all of them." But more realistically, I think you are correct that determining which subcommands should be made available through this configuration is up to the implementer. It may be the case that some just don't make sense to wrap.
As of right now, these are the only Borg subcommands wrapped by borgmatic's
extra_borg_options:init(which incidentally should probably be renamed torepo-createat some point)createprunecompactcheckAlright
Got it
i will open up a pull request on the subject
I left message a message in the IRC chat as well regarding my proposal
I'm not seeing it there, so you might want to include it on this ticket. Thanks.
It was just a link to my proposal and review
But time is late
But here is the link
Link to the docs
I couldn't complete it in time. but I hope I can proof my ability to work before the results are out
I'll like to be assigned this issue
And proceed working on it
Sorry, @witten, that comment I left was via Element
Oh no worries! We received your proposal on the main GSoC website as well.
But in regards to this ticket, pull requests are always welcome! Thank you.
Taking a look at the borgmatic folder structure, I'm a bit confused precisely where the extra sub commands from borg are added. Currently I notice two folders [
Borg,Actions] share the same file and coding structureSo do this folders describe the different operations carried out on borg like the
actionsfolder containsborgactions while thecommandsfolder contains thesub commandsfor the borg actionsIf that's the design, wouldn't it be better to rename the
commandsfolder tosub_commandsto be more clear?Please check out the source code reference, which hopefully answers many of these questions. In borgmatic, "sub-commands" are called "actions." So the
actionsdirectory contains borgmatic-specific logic for its own actions, while theborgdirectory contains Borg-specific logic for them (calling out to Borg sub-commands).commands, in contrast, contains code for top-level commands likeborgmaticincluding all the argument parsing it does for both actions and global flags.oh sorry my bad for not checking the docs properly
I'd open a draft PR on this to proceed
Thanks for the reply
No worries!
extra_borg_optionswith other commands #1103Well, I thought somebody would implement this in the last four plus years. Turns out, in the end, that somebody was me. 😄
This feature is implemented in main and will be part of the next release. Every Borg sub-command that borgmatic uses now has an option under
borg_extra_options. In cases where a sub-command is hyphenated, the corresponding option name has an underscore instead.Also, as part of this change, the
initoption underborg_extra_optionsis deprecated in favor ofrepo_create. Both still work though.Released in borgmatic 2.0.10!