Native support for borg recreate (using config yaml, not arbitrary borg command line) #610
Reference in New Issue
Block a user
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
Clean out old backups that have obsolete data so I don't have to pay more for borgbase.
Steps to reproduce (if a bug)
borgmatic -c config.yaml borg recreate --exclude 'olddata.file'or
borgmatic -c config.yaml borg recreate --exclude 'obsoletedir/*'Actual behavior (if a bug)
it works fine but is cumbersome
Expected behavior (if a bug)
if I had my way:
borgmatic -c config.yaml recreate(and that's it.. updates to exclude patterns in config.yaml or referenced exclude.txt automatically take care of themselves)
e.g. in the yaml I could:
and then run borgmatic recreate and it'll refresh all those old archives.
Other notes / implementation ideas
See above. I'd like to just edit my config files and excludes and have that just "work" when doing a
borgmatic recreate. Essentially it brings the whole repo up to date without much configuration.It would save a lot of time trying to figure out where I had backed up data I didn't actually need to back up and remove it from all archives.
Environment
borgmatic version: [1.7.4]
borgmatic installation method: [sudo pip3 install --upgrade borgmatic]
Borg version: [1.1.6]
Python version: [3.9.2]
Database version (if applicable): [N/A]
operating system and version: [Debian Bullseye (proxmox 7)]
That makes sense to me as a feature! I hadn't thought about the exclude integration before.. that's a nice idea. Thanks for taking the time to file this.
It just seemed like it was an obvious way to handle retconning my data. There's already all that exclude setup in place, why not extend it to recreate?
Incidentally, you may want to look at the other options recreate can take and how they can be implemented with config yaml changes. E.g. compression, comments, what have you.
Thanks!
This should be similar to what borgmatic does for
borgmatic createright (except the extra arguments that borgmatic create can take)?It should take the source repos from config and overwrite them (considering the new config).
Or take one repo via
--repositoryand overwrite it.And it should ignore any changes to the config that
borg recreatedoes not account for?Quick links for differences between the args
borg recreateandborg createtake -https://borgbackup.readthedocs.io/en/stable/usage/recreate.html, https://borgbackup.readthedocs.io/en/stable/usage/create.html
Also,no support for overwriting a particular archive?
Looks like an interesting task, I would like to work on it!
Will look at the other borgmatic commands.
That all sounds reasonable.
I think it could go either way. There's at least one example on the
borg recreatedocs that do this. So you could support that with a borgmatic--archiveflag if you wanted to.Any news on this? I keep creating and removing VMs and all the old VMs that I never intend to use again are lingering in my archives.
As far as I know, no one is working on this one right now. Pull requests are always welcome. 😄
Understood. I best get learning to code I guess.
I would like to try my luck with this.
Awesome, welcome to the borgmatic project! Please have a look at the docs on how to get started with development! It might also save you time if you wanted to outline your approach to the ticket here to get feedback before you start writing code, especially since this is one of the larger "good first issue" tickets.
In terms of where to start in the source code once your design is locked down:
borgmatic/commands/arguments.pyis where the CLI interface for each action is defined.borgmatic/actions/recreate.pyis where any borgmatic logic for the newrecreateaction should go.borgmatic/borg/recreate.pyis where the code to actually callborg recreateshould go.borgmatic/unit/tests/...contains the hierarchy of unit tests. Look at some of the existing actions for inspiration.And let me know if you have any questions!
Hey witten
Thanks for the heads up! I've been working with Vorta, so I'm fairly new to the Borgmatic codebase. Once I fully understand the relevant parts needed for this implementation, I’ll go ahead and create a PR and explain the process.
For now, I’m thinking of looking into how
createis implemented and using that as inspiration forrecreate. I’ll keep you updated on my progress!I do have a question, it's about testing the changes. From my current understanding, running
toxwill run the unit tests, right? I’m wondering how to manually test the changes. Does runningtoxalso build the execuatableborgmatic? Or can I just runborgmaticstraight after making changes to the code?Any guidance on how to manually test would be really helpful, Thanks
After I make changes, I run(to build editable)
pip install -e .and thentoxto test across all python versions in tox.ini file.Sounds good! Just be aware that
createis one of the most complex actions in borgmatic. So while it's probably the closest torecreate, it may also help to look at some of the simpler actions as well.@120EE0980 is correct. Installing editable (via
pip install -eorpipx install -e) and then runningtoxwill indeed run tests. But to manually test your changes, yes, you should be able to just runborgmaticright after making modifications to the code. This doesn't have anything to do withtoxthough.. It's the magic of that editable install that lets you run your changes directly.Got it! Thanks guys
Also witten, can I consider this as my borgmatic project for the proposal? This is like the subset of what I had in mind, but now that I looked into this a bit more, I think with all the additions and tests to be written, it's a small project on it's own.
Once I finish this I'll have a good understanding of adding borgmatic actions, then I can proceed to add the rest of actions, instead of jumping the gun, I think that will be a smoother transition.
My thinking is that any relevant project can be put into a proposal, not just one of the ideas listed on the GSoC ideas page. So what I'll do is remove the "good first issue" tag because I agree that it's a little bit bigger of a project even if it's (mostly) straightforward. In terms of moving forward on GSoC though, just make sure you're going through the steps listed here. (It sounds like you've already done some of them with Vorta.)
Thanks!
This is implemented by @VandalByte in main and will be part of the next release!
Released in borgmatic 2.0.0!