Feature Request: support for --strip-components all (or similar) #647
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#647
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?
Hey guys,
first off thanks for borgmatic, it's awesome! After trying it out I've decided to replace all three of my current backup solutions (Duplicati, Time Machine, self-written shell script) with the borg / borgmatic combination. I really love it - it's so lean and simple.
I have one use case that's a bit clunky though. Usually I'll search the archives for that one file, then go through its versions to see if any of them contains what I'm looking for.
When I run
borgmatic extract
, the file will be downloaded to my current working directory, but with all its parent directories. I can fix this by counting the parent directories and using--strip-components 4
for example, but it would be much nicer to have something like--strip-components all
or--remove-parent-directories
.borgmatic version: 1.7.8
borgmatic installation method: brew
Borg version: 1.2.3
operating system and version: macOS Ventura 13.2.1
Thanks for using borgmatic and taking the time to write up this feature! It sounds like a great idea to me, especially since borgmatic already has a
--destination
flag. But given that such a feature isn't (currently) in Borg and would have to be done at the borgmatic level, the only issue I can see is that there could potentially be collisions during extraction. For instance, if you're extracting multiple files likefoo/file.txt
andbar/file.txt
and you use--remove-parent-directories
or whatever, then what should borgmatic do? Error? Maybe this isn't something for you to worry about now, but just an edge case for the implementer to deal with.When you do use
borgmatic extract
today, do you use the--path
flag with the path for a single file? And then do youmv
it to wherever you want it to go? Or did youcd
to its desired parent directory first (or use--destination
)?In any case, this removal of parent directories would have to be a post-processing step done by borgmatic after Borg performs its usual extraction into nested directories.
I assume you're aware of the
--find
feature, which makes this process a little more streamlined. However it won't show you the contents of the file.You are right, of course.
I was using the
--find
feature which is great by the way, and one of the reasons I switched from Time Machine. I love that I can see all the versions of the file, including modification time and file size. That helps a lot when looking for a specific change.Then I would do cd to my download directory (
~/Desktop/test
for example) and do aborgmatic extract
with a single argument to the--path
flag. For that scenario, a--remove-parent-directories
would be convenient. But I agree this feature isn't so straightforward once there are multiple arguments to--path
. One could--remove-parent-directories
allows only one argument to--path
All of these options feel a bit icky though, so unless you have a better (cleaner) idea, I suggest we put this idea on the "nice to have" stack π
Any of those options make sense to me. Thanks for the details and the brainstorming. Honestly I'd probably look at what "native"
borg extract
does and try to mimic its overwriting behavior.Borg's "native"
extract
behavior: Silently overwrite. πI mean that would be just fine for my use case. And if Borg already does it, it would be consistent for the user, too.
I ended up going with your original
--strip-components all
idea, in large part because it lets me lean on Borg to do the heavy lifting. What borgmatic does is simply count the leading path components in any specified--path
s, take the maximum, and pass that number to Borg's--strip-components
. Seems to work!The main downside is that this won't work when no
--path
s are specified. In that case, borgmatic just errors.Thanks again for suggesting this. It'll be part of the next release!
Wow nice, thanks so much π looking forward!
Just released in borgmatic 1.7.9!
I just updated borgmatic and tried it - works like a charm π