untar corrupted tar file

Hi,

I created a tar file of some data on a ftp site and now am trying to download it. When I download it it comes all the way down but then I try to untar it with tar xf SL-ORP.tar and when I do I get the following error:

tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
tar: A lone zero block at 4628425
tar: Error exit delayed from previous errors

I've tried downloading the file a number of times in case the file got corrupted in transit, but I've gotten the same error each time. I'm guessing this means my file is corrupted. I've also tried untarring it with Stuffit Expander but it telIs me

"An error has occured while expanding the file "SL-ORP.tar" (Folder not found).

Error #-120

Is there any way to recover part of the tar file so I don't have to recreate all of it? Thanks very much.

-NifflerX

Posted on Oct 17, 2005 10:40 AM

Reply
7 replies

Oct 17, 2005 5:54 PM in response to nifflerX

NifflerX,

Well do you like to program?

I would think that it might be possible to extract the file. either with a perl script or a C program. To see what the format looks like grab the header files that come with gnutar. You might even be able to do it manually using a combination of xxd and dd. xxd to show where your file is located within the tarball. and dd to extract it. It would take some experimenting. but does look like it's possible.

dd if=<your tar file> \
skip=<offset to the file to extract> \
bs=<size of file> \
count=1
of=<filename>

Just a thought.

Andy

Oct 17, 2005 6:42 PM in response to Nils C. Anderson

Granted this is a tad bit contrived. But here a rough example of using xxd and dd. I would not be very useful for extracting many files though.

tar -tvf gnutar-433.tar | less

-rw-r--r-- root/admin 512 2003-09-09 15:39:13 gnutar-433/gnutar/m4/hash.m4

xxd gnutar-433.tar
.
.
.
0307c00: 2320 6861 7368 2e6d 3420 7365 7269 616c # hash.m4 serial
.
.
.
0307df0: 5f53 5444 424f 4f4c 5f48 5d29 0a5d 290a STDBOOLH]).]).
0307e00: 676e 7574 6172 2d34 3333 2f67 6e75 7461 gnutar-433/gnuta
0307e10: 722f 6d34 2f68 756d 616e 2e6d 3400 0000 r/m4/human.m4...

0x0307e00 - 0x0307c00

size 496

dd if=gnutar-433.tar skip=3177472 ibs=1 count=512 of=/tmp/hash.m4

Oct 18, 2005 8:07 AM in response to Nils C. Anderson

Hi,

Thank you so much for the programming tips. As it turned out I was able to get most of the file recovered without programming. In case this helps anyone else I'll detail what I did.

Using the script find tarheaders.pl, which can be found here and the instructions found at the same place I was able to use the tail command to skip ahead in the tar file to an uncorrupted portion. However, I wasn't able to use the instructions on the website as is, I had to add 1 to the header file number that was produced from find tarheaders.pl. Once I had a valid byte offset, I added one to it, ran the following command:

tail -c <offset1> SL-ORP.tar > extracted.tar


and then untarred extracted.tar. It worked and I know have everything after the offset. Hope this helps someone in a similar situation, 'cause I know I had corrupted tar files.

-NifflerX

Oct 19, 2005 8:01 AM in response to nifflerX

Just as an addition. I talked to the guy who maintains the website and he changed the find tarheaders.pl script so that it now takes into account the +1 for the offset automatically. So, according to him you no longer need to add 1 to the header location, instead just use the offset number as it comes out of the find tarheaders.pl script.

-NifflerX

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

untar corrupted tar file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.