Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--directory option for borg create and extract #1783

Open
gleb opened this issue Oct 31, 2016 · 11 comments
Open

--directory option for borg create and extract #1783

gleb opened this issue Oct 31, 2016 · 11 comments

Comments

@gleb
Copy link

gleb commented Oct 31, 2016

man tar:

     -C, --directory DIR
           change to directory DIR

man tarsnap:

     -C directory
             (c and x modes only) In c mode, this changes the directory before
             adding the following files.  In x mode, change directories after
             opening the archive but before extracting entries from the ar‐
             chive.

Would be nice to have this.

@ThomasWaldmann
Copy link
Member

I never got the point of these. Why not just cd before invoking tar/tarsnap/borg?

@gleb
Copy link
Author

gleb commented Oct 31, 2016

Personally I use it occasionally in scripts, for atomicity (in case cd fails) and lack of side effects (no need to cd back). tar -C /home is equivalent to something like cd /home && { tar ; cd - }

But I just looked at the docs https://www.gnu.org/software/tar/manual/html_node/directory.html and apparently it is meant for something else - you can use -C multiple times within tar arguments and pretty much write a program inside tar. Who knew.

And now that I know, I'd say implementing this is best avoided for now. Too complicated for not enough gain.

@edgewood
Copy link
Contributor

edgewood commented Nov 1, 2016

On Sun, Oct 30, 2016 at 10:15:21PM -0700, gleb wrote:

Personally I use it occasionally in scripts, for atomicity (in case cd fails) and lack of side effects (no need to cd back). tar -C /home is equivalent to something like cd /home && { tar ; cd - }

Note that starting a subshell will isolate environmental changes
(including working directory) to the subshell. No need to change things
back to the way they were, just copy the current environment, change the
copy, and throw the copy away when you're done.

For example:
( cd /home && borg create ... )

Ed Blackman

@gleb
Copy link
Author

gleb commented Nov 2, 2016

Good point, thanks!

@MarkMielke
Copy link

I wanted the ability to treat the source directory as irrelevant. This seems to be possible with:

cd /source/directory && borg create ARCHIVE "."

Using --directory or similar would formalize this capability and make it easier to access.

I haven't yet found documentation approving of the "." as a valid use case, so I'm partially concerned that I'm doing something wrong, and this lead me to this issue.

@ThomasWaldmann
Copy link
Member

There is nothing wrong with . (just make sure you are really where you want to be).

@alexconstsh
Copy link

@ThomasWaldmann Is there anything missing from @unilynx's code mentioned in #5604?

@ThomasWaldmann
Copy link
Member

@alexconstsh yeah:

  • it should not be in a "docker issue" (but rather here)
  • there should be a PR request to discuss it
  • docs
  • tests

@alexconstsh
Copy link

@unilynx hi. Are you willing to continue work on this feature? If not, I would like to take your code under Borg's license and work from there.

@unilynx
Copy link

unilynx commented Sep 28, 2021

@unilynx hi. Are you willing to continue work on this feature? If not, I would like to take your code under Borg's license and work from there.

By all means, go ahead! I still haven't gotten around to it and it would be nice to have.

@ThomasWaldmann ThomasWaldmann added this to the 2.0.0b6 milestone Apr 7, 2023
@ThomasWaldmann ThomasWaldmann modified the milestones: 2.0.0b6, 2.0.0rc1 May 12, 2023
@ThomasWaldmann
Copy link
Member

See also #4685 for more problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants