Link to home
Start Free TrialLog in
Avatar of bin2003
bin2003

asked on

Extract a folder from a tgz file

I have a backup of my sever each night that creates a tgz file. In the file are many folders with many files. I wish to just extract one particular folder (it has thousands of text and pdf files in it ).

What is the syntax to extract just a folder of files and put it back in the correct place?

Thank you  
Avatar of Barthax
Barthax
Flag of United Kingdom of Great Britain and Northern Ireland image

Create a file which lists the necessary directory/directories you need to extract - be sure to include the wild card characters.

You can then use the file in the extraction process by specifying the --from-file= parameter:

tar -zxvf --from-file=myfileselection.txt mygzippedtarfile.tgz
Avatar of bin2003
bin2003

ASKER

Thank you. How does this know which folder to extract to? Do I have to extract to folder where I have the tgz file then copy/move them to correct folder afterwards?
ASKER CERTIFIED SOLUTION
Avatar of Barthax
Barthax
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just do:

cd /
tar zxvf /path/to/backup.tgz path/to/folder/to/be/restored