So you thought you had your files backed up - until
it came time to restore. Then you found out that you had bad sectors and
you've lost almost everything because gzip craps out 10% of the way through
your archive. The gzip Recovery Toolkit has a program - gzrecover - that
attempts to skip over bad data in a gzip archive. This saved me from
exactly the above situation. Hopefully it will help you as well.
99% of "corrupted" gzip archives are caused by transferring the file via FTP in ASCII mode instead of binary mode. Please re-transfer the file in the correct mode first before attempting to recover from a file you believe is corrupted.
This program is provided AS IS with absolutely NO WARRANTY. It is not guaranteed to recover anything from your file, nor is what it does recover guaranteed to be good data. The bigger your file, the more likely that something will be extracted from it. Also keep in mind that this program gets faked out and is likely to "recover" some bad data. Everything should be manually verified.
For tarballs, the tar program will choke because GNU tar cannot handle errors in the file format. Fortunately, GNU cpio (tested at version 2.6 or higher) handles corrupted files out of the box.
Here's an example:
If you have a previous release, please note that the patches to GNU tar have been discontinued. They were only marginally successful at best and GNU cpio does what is needed out of the box and does it far better.
99% of "corrupted" gzip archives are caused by transferring the file via FTP in ASCII mode instead of binary mode. Please re-transfer the file in the correct mode first before attempting to recover from a file you believe is corrupted.
This program is provided AS IS with absolutely NO WARRANTY. It is not guaranteed to recover anything from your file, nor is what it does recover guaranteed to be good data. The bigger your file, the more likely that something will be extracted from it. Also keep in mind that this program gets faked out and is likely to "recover" some bad data. Everything should be manually verified.
Downloading and Installing
You need the following packages:- gzrt-0.7.tar.gz (2013-02-02) - gzrt sources
- github repository
- zlib - You might already have this.
- GNU cpio (version 2.6 or higher) - Only if your archive is a compressed tar file and you don't already have this (try "cpio --version" to find out)
make. Install manually by copying to the directory of your
choice.
Usage
Run gzrecover on a corrupted .gz file. Anything that can be read from the file will be written to a file with the same name, but with a .recovered appended (any .gz is stripped). You can override this with the -oFor tarballs, the tar program will choke because GNU tar cannot handle errors in the file format. Fortunately, GNU cpio (tested at version 2.6 or higher) handles corrupted files out of the box.
Here's an example:
$ ls *.gz my-corrupted-backup.tar.gz $ gzrecover my-corrupted-backup.tar.gz $ ls *.recovered my-corrupted-backup.tar.recovered $ cpio -F my-corrupted-backup.tar.recovered -i -vNote that newer versions of cpio can spew voluminous error messages to your terminal. Also, cpio might take quite a long while to run.
If you have a previous release, please note that the patches to GNU tar have been discontinued. They were only marginally successful at best and GNU cpio does what is needed out of the box and does it far better.