Borgmatic delete? #298
Loading…
x
Reference in New Issue
Block a user
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
delete
command, 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 delete
works 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-run
with-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_directory
than default in borgmatic... When usingborg
to do the delete, I always forget to point at that different cache, and I think the default~/.cache/borg
gets 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 --help
but didn't see anything because I was on an old version. Just updatedCool! I agree that a native
borgmatic delete
would be helpful too.I tried
borgmatic borg delete MY-hostname-2022-01-25T17:20:35.335171 Tue, 2022-01-25 17:20:35
and 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 delete
borg delete
the latest version of
borg delete
has 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
--repository
and--archive
are 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 list
accepts both--match-archives
and--glob-archives
, and in fact they are a single Python argument with an alias. Seelist_group
inborgmatic/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 delete
works? 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
--repository
on thedelete
action 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
rdelete
sub-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=False
ifaction='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!