Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2005
    Posts
    533

    how can I extract certain file from tar.gz

    Hello,


    I have a huge backup file in tar.gz format.
    now I need a file from this backup file,
    for example I need extract only index.php located in homedir/public_html on tar.gz file.

    How can I do it ?

  2. #2
    Join Date
    Mar 2008
    Location
    UK.
    Posts
    225
    Current Status: Coming up with ideas for a new SaaS.

  3. #3
    Join Date
    Apr 2002
    Location
    Auckland - New Zealand
    Posts
    1,572
    Yes you can do this easily

    # man tar

    tar -xzf foo.tar.gz blah.txt
    extract the file blah.txt from foo.tar.gz

  4. #4
    Join Date
    Mar 2005
    Posts
    533
    I found another way in the net, my problem solved and everybody who has this problem can use this:

    Code:
    zcat file.tar.gz | tar xvf - file_to_extract

  5. #5
    Join Date
    Mar 2002
    Location
    London, UK
    Posts
    104
    webhostbeginner, you can also use
    tar zxvf --include='*homedir/public_html/index.php' file.tar.gz
    Todayhost Limited (reg no: 05658437)
    Dedicated Web Hosting and Colocation Services

  6. #6
    Join Date
    Apr 2002
    Posts
    930
    Actually you can just use:

    Code:
    tar -zxvf file.tar.gz <path of file in tarball>
    Where <path of file in tarball> is just the path as it is seen inside the tarball. You can view the files and file structure in the tarball by using:

    Code:
    tar -ztvf file.tar.gz
    For example, say you are using a cPanel backup file and you want to extra the index.html file:

    Code:
    tar -zxvf file.tar.gz username/homedir/public_html/index.html
    The -v option isn't necessary in any of these examples, it just gives verbosity.

  7. #7
    I just use winrar?

  8. #8
    Join Date
    Aug 2003
    Location
    Utah
    Posts
    274
    Quote Originally Posted by Rehat View Post
    I just use winrar?
    LOL, I was going to say the same thing. But they did say this tarball is HUGE. Therefore, downloading is a bit less practical to extract a small file or whatever.

    Most of my backups are small enough to download and extract what I need manually.

    Still, I highly recommend downloading your backups weekly and store them on DVD or a USB drive.
    BestVPSReviews.com - KnownHost VPS? Liquid Web VPS? See my personal experience with these hosts.
    Best Web Hosting - The Best Web Hosting Deals and News

  9. #9
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    298
    Quote Originally Posted by Rehat View Post
    I just use winrar?
    You lazy toad
    SuperRacks Ltd European Hosting
    We serve you with custom services
    Visit our website or ask for a custom quote
    Quality linux and Windows hosting, servers and collocation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •