Koozali.org: home of the SME Server

How to restore a single file using DAR

Offline Bozely

  • *
  • 75
  • +0/-0
How to restore a single file using DAR
« on: October 11, 2017, 11:37:53 AM »
Hi all,

I have for a long time used DAR on the command line to restore folders but have never been able to restore a file inside a directory.

Code: [Select]
dar -R / -x /zip/linux_full -v -g home/docs/my_precious_directory
Restores perfectly but when I specify a single file like so

Code: [Select]
dar -R / -x /zip/linux_full -v -g home/docs/my_precious_file.txt
It goes through the archive but restores nothing. What am I missing?

As far as I can tell I am following the manual
http://dar.sourceforge.net/doc/Tutorial.html


Offline holck

  • ****
  • 317
  • +1/-0
Re: How to restore a single file using DAR
« Reply #1 on: October 11, 2017, 11:57:54 AM »
I have had problems with this myself. I've found this way to do it:

Code: [Select]
mkdir recoverdir                                            # Create a temporary directory
cd recoverdir                                                 # ... and enter the directory
dar -x myfiles.dar -g home/docs/my_precious_directory    # extract  the sub-directory with the precious file
mv my_precious_file.txt /home/docs/my_precious_directory # and put it back where it belongs
cd ..
rm -r -f recoverdir                                              # clean up
[/font]

It's not elegant, but it works ...
« Last Edit: October 11, 2017, 01:41:35 PM by holck »
......

Offline Bozely

  • *
  • 75
  • +0/-0
Re: How to restore a single file using DAR
« Reply #2 on: October 11, 2017, 01:39:34 PM »
Thanks,

Exactly how I've worked around this until yesterday when I needed to restore one small file in a huge directory and I didn't want to restore the whole thing.

Hoping there is something more concrete on how to do this, may end up writing a custom script...