Borg: Feature Request: --ignore-dir

Created on 14 Oct 2016  路  9Comments  路  Source: borgbackup/borg

When extracting a file from the repo, the whole original directory structure is recreated.That is generally fine, but sometimes I just need one file from the archive and I want it to be placed in the current folder where I am right now.

Therefore I suggest adding the --ignore-dir switch to the borg extract optional arguments.

So:
user@local ~/test $ borg extract --ignore-dir /path/to/repo::first 'home/user/dir/subdir/subsubdir/my_important_file.txt'

should end up in
~/test/my_important_file.txt

and not in
~/test/home/user/dir/subdir/subsubdirmy_important_file.txt

wontfix

Most helpful comment

If you want to do this right now, consider something like...

$ borg extract ... invoice*.pdf
$ mv **/*.pdf .
$ rm -r */

All 9 comments

Have a look at extract options, there is already --strip or so, which is just a more flexible version of what you suggest.

Not quite, if I understand the help text correctly.

I have to tell _--strip-components_ how many leading path elements I want removed. That is fine for one file or if all the files I want to extract reside in the same directory.

But if I want to extract '*.txt' from everywhere in the archive to the current directory, then this won't help, because then the number of leading path elements will vary from file to file.

What I suggest is an option to strip all and any leading path elements, no matter how many there are.

This should be fairly easy to implement with the current strip components code and some minor refactoring.

the use case where this would be useful (but --strip-components is not) sounds rather too special for me. it is only if you want to reorganize your files in a different way than they were when you backed them up and it is questionable whether this is the job of a backup software.

My use case scenario is as follows:

I run my own company, and for whatever reason, I just need to look at some old invoices from some years ago. They are in directories

/home/user/companystuff/1998
/home/user/companystuff/1999
/home/user/companystuff/2000
/home/user/companystuff/2001

In those directories are also other files, but I just need the invoice_xxxx.pdf files from each of these folders.

So, doing

borg extract --ignore-dir /mnt/backup/repo::2001 invoice*.pdf

should extract the files to the current direcory.

I wouldn't mind the name of the option if

borg extract --strip-components ALL /mnt/backup/repo::2001 invoice*.pdf
or
borg extract --strip-components all /mnt/backup/repo::2001 invoice*.pdf

would do the job.

If you want to do this right now, consider something like...

$ borg extract ... invoice*.pdf
$ mv **/*.pdf .
$ rm -r */

close?

I still believe a --ignore-dir option would be a good thing, but if you think that is too special then I can live with the solution which enkore offered.

^

Was this page helpful?
0 / 5 - 0 ratings

Related issues

verygreen picture verygreen  路  4Comments

tconstans picture tconstans  路  5Comments

pierreozoux picture pierreozoux  路  4Comments

zatricky picture zatricky  路  3Comments

rugk picture rugk  路  4Comments