Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 '14 at 16:39

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
gunzip filename.tar.gz worked for me. – Ravi Dhoriya ツ Jan 19 '15 at 9:00

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

Full recovery is not possible. Formats like .zip provide better protection and recovery options, but not full either.

.tar.gz lumps all files together and then applies a compression. .zip restarts compression for each file. Therefore in .zip file a damage done to compressed block only affects the file to which this block belongs. In .tar.gz the damage will affect all subsequent files until compression is somehow restarted.

share|improve this answer

All recpies apply only for extracting info from begin of file to point where error occured, or where file is cutted.

Unfortunately no one recipie describies how to recover part of file/stream after corruption area. Has anybody that recipie?

share|improve this answer

Your Answer


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.