Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I suddenly needed to recover an old tar.gz file, but as soon as I execute so:

tar -zxvf filename.tar.gz

I get this:

gzip: stdin: invalid compressed data--format violated  
tar: Child returned status 1  
tar: Error is not recoverable: exiting now
share|improve this question
4  
Is that really a gzipped tarball? Try file command on it first. –  alex Jul 27 '11 at 5:42
    
Yes, it has happened to me more than once that I got a .tar.gz which was really a .tar, and once even a PDF. –  vonbrand Feb 25 at 16:39

3 Answers 3

What you should try is the following:

  1. Use file command on the archive to see if it's recognized as gzip-ped data.
  2. Run strace gunzip on the file. This will print the last bytes read from the file which might help you identify the point in file where corruption occurs.
  3. Run a debug build of gunzip under gdb. Try to correct the corrupted section (you have to be extra lucky to be able to do that) and see if it can continue to the end of the file.

Depending on the nature of corruption, you might or might not be able to recover your data.

share|improve this answer

Run zcat bad.tar.gz > some.tar, and extract that. Going past the corrupted part of the file will be tricky. The man page gives pointers to the format, but I'd look for other options in Google.

Are you sure this is compressed with gzip? It might be complaining because it doesn't understand the format...

share|improve this answer

Some info about how recovery works can be found at Recovering a damaged .gz file

There also is a tool that helps you doing this: gzip Recovery Toolkit aka gzrecover

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.