Borgmatic delete? #298
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
6 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#298
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
Delete specific archives within a repository
Other notes / implementation ideas
Would it be possible to have a
deletecommand, similar toborg delete, to destroy specific archives within the repositories? I could do it withborg delete, but that would lose all the nice setup specified in borgmatic :)Environment
borgmatic version: 1.5.1
borgmatic installation method: Pip
Borg version: 1.1.5
Python version: 3.6.9
operating system and version: Ubuntu 18.04.3 LTS
Seems like a reasonable addition. Could you talk a little about the use case where
borg deleteworks better for you than automatic pruning? That would help me understand the motivation a bit. Thanks for writing up the idea!I needed to delete a range of backups that contained a set of files.
But I realise this is tricky, because each repository has different archive name with using {utcnow}.
So alternatively, and instead of having to reimplement every single borg command, how about a borgmatic command that just outputs a pre-filled borg command-line with the right setup (environment variables, repos, maybe repo passphrase in a securefile sourced with "PASSCOMMAND", etc). Then the user would just have to add the final borg commands they need.
Would that make more sense?
You can kind of get that now by using
--dry-runwith-v 2. But yeah, it doesn't enclude all environment variables, etc.I'm fine adding
borgmatic delete, and indeed borgmatic is slowly growing to wrap more and more Borg actions. I just wanted to better understand your use case first. Makes sense to me.To add my 2c here; I'd like this too. What I've noticed is that, I like to use a different
borg_cache_directorythan default in borgmatic... When usingborgto do the delete, I always forget to point at that different cache, and I think the default~/.cache/borggets used, confusing things.Bump. I'd also love a delete feature. Honestly, it would be nice if you could just run any arbitrary borg command using the relevant config from borgmatic (e.g. ssh command, encryption keys, etc).
My particular need is that I want to delete a whole set of backups. I can prune down to 1, but then I manually have to delete that one anyways
Have you tried
borgmatic borg delete? 😄Oooh! Awesome! I thought there might be something like that, and I checked
borgmatic --helpbut didn't see anything because I was on an old version. Just updatedCool! I agree that a native
borgmatic deletewould be helpful too.I tried
borgmatic borg delete MY-hostname-2022-01-25T17:20:35.335171 Tue, 2022-01-25 17:20:35and it did delete the archive but there is an errr/warning showing up.
Is that ok? @witten
The archive name looks like it's just
MY-hostname-2022-01-25T17:20:35.335171. The rest of it (Tue, ...) is not part of the archive name—that's just additional information about the archive that Borg provides. So the full command would look more like:My bad, thanks as always!
I want to work on this issue if this is available 😄
It's still available! Thanks for checking, and let me know if I can help in any way.
I was looking into the documentation for Borg command and I have a question in general that between Borg 1 and Borg 2, a lot of commands have changed. For example between these versions,
borg deleteborg deletethe latest version of
borg deletehas more archive filters.We are targeting full coverage for Borg 1 commands ... but at some point we will have to support Borg 2 commands.
So, I was wondering that is there any approach that we follow right now so that we might support Borg 2 commands with minimal change?
Also, if both
--repositoryand--archiveare not passed, should delete all repositories?The approach I've been taking to that has varied based on the specific Borg flags. Some examples relevant to this ticket:
borgmatic listaccepts both--match-archivesand--glob-archives, and in fact they are a single Python argument with an alias. Seelist_groupinborgmatic/commands/argument.py:make_parsers()for where that happens.borgmatic check, the flags passed to Borg vary based on the version of Borg found. Seeborgmatic/borg/check.py:make_check_flags(), specifically the call tofeature.available().borgmatic transfer, and an example flag like this isborgmatic init/rcreate --source-repository.For the new Borg 2 archive filters you're referring to (
--oldest,--newest, etc.), I'd be fine with leaving those unimplemented for now and filing them in another ticket. Nothing else in borgmatic implements them since they're so new.Is that how plain
borg deleteworks? I couldn't tell from the documentation. It might be safer not to do this unless an explicit archive filter is provided that matches all archives.That makes sense, although in practice there's probably not going to be an archive with the same name in multiple repositories. It might be safer and more sensible just to require
--repositoryon thedeleteaction if multiple repositories are configured. (There are existing borgmatic actions that do this.)I'd say it should error. After all, Borg 2 has a separate
rdeletesub-command for this purpose. I'm personally not fussed if we don't support doing this in Borg 1.x.Hope this helps!
In the
arguments, is it necessary to mentiondefault=Falseifaction='store_true'is passed? From the docs it seems unnecessary to mention it.I would trust the docs on this one. 😄
@Soumik_Dutta, are you still planning on working on this? No worries either way.. I just want to know if this ticket is available to work on. Thanks!
No, I am not working on this code anymore. Please feel free to assign this to someone else @witten
Implemented in main and will be in the next release!
Released in borgmatic 1.8.13!
With a lot of delay: thanks a ton !