Feature Request: support for --strip-components all (or similar) #647
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#647
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?
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 4for example, but it would be much nicer to have something like--strip-components allor--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
--destinationflag. 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.txtandbar/file.txtand you use--remove-parent-directoriesor 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 extracttoday, do you use the--pathflag with the path for a single file? And then do youmvit to wherever you want it to go? Or did youcdto 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
--findfeature, 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
--findfeature 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/testfor example) and do aborgmatic extractwith a single argument to the--pathflag. For that scenario, a--remove-parent-directorieswould be convenient. But I agree this feature isn't so straightforward once there are multiple arguments to--path. One could--remove-parent-directoriesallows only one argument to--pathAll 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 extractdoes and try to mimic its overwriting behavior.Borg's "native"
extractbehavior: 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 allidea, 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--paths, 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
--paths 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 π