*Resolved* - Need to recover corrupt bzip2 files..
I've solved the problem in a round-about way, so here's how i did it:
1. Use bzip2recover to recover the individual bzip2 blocks (900k by default)
# bzip2recover corrupt.tar.bz2
which gernerates chunks:
rec00001backup.tar.bz2
rec00002backup.tar.bz2
rec00003backup.tar.bz2
etc..
2. Send bzip2 test results to a file for searching (could also grep right here if you want):
#for i in *.bz2; do bzip2 -tvf $i >> corruptblocks.out 2>&1; done
3. Search the test results for errors
# grep -i CRC corruptblocks.out
4. Delete the corrupt block
# rm <corruptblock>.tar.bz2
5. Untar all of the bzip2 blocks elsewhere
# for i in *.bz2; do bzip2 -dcvf $i > /elsewhere/$i.tar; done
6. Here you need to look for the first occurence of a tar header prior to the corrupt block. A tar block basically consists of the tar header filename (eg the actual file archived - /pictures/easter/pic02.jpg), followed by tar header metadata (doesn't matter), followed by the actual data. A tar archive is just made up of sequential tar blocks. The aim is to remove the entire tar block in which the corrupt bzip2 block lived. The untaring will continue as if the corrupt tar block never existed.
I did it using a hex editor as I wasn't too sure in which actual file (from the filesystem) the error had occured. So if the corruption occurred in block 1000, I would check through block 999, then 998 etc... If you know that you were backing up the "/pictures" directory and it failed around the "/pictures/easter" directory, then greping for "/pictures/easter" in the few blocks prior should find a match. You need to do the same to find the closest tar header AFTER the corrupt block. Remember that it needs to be just the tar block in which the corruption occured.
Eg.
block997.tar - Closest preceeding header (/pictures/easter/pic01.jpg)
block998.tar
block999.tar
block1000.tar - CORRUPT BLOCK
block1001.tar
block1002.tar - Closest trailing header (/pictures/easter/pic02.jpg)
a. Here you would open block997.tar and remove ALL data from the start of the header (/pictures/easter/pic01.jpg......) to the end of the file (the first "/" char onwards).
b. Make sure you delete block998.tar, block999.tar, block1000.tar (should have already been deleted earlier) and block1001.tar.
c. Open block1002.tar and remove ALL data from the byte prior to the start of the next header (/pictures/easter/pic02.jpg) to the start of the file (the new file should now start with /pictures/easter/pic02.jpg as opposed to raw data)
(After this, the tar block with the corrupt data should have been removed)
7. Glue everything back together using:
# cat /elsewhere/*.tar > recovered.tar
8. Untar as usual to recover existing data
* tar -xvf recovered
Hope this helps.
Last edited by rhinomite; 02-15-2005 at 05:04 PM.
|