Recovering corrupted tar's

Erik Naggum enag at ifi.uio.no
Fri Oct 5 08:12:56 AEST 1990


In article <4121 at neuro.med.umn.edu> alk at neuro.med.umn.edu (Anthony L Kimball) writes:

   So, anyone have a handy-dandy tool to patch a tar archive which
   has had it's leading N blocks overwritten?  I do so hate to do this
   by hand.

The files occupying the first n blocks are lost, where n >= N.  The
problem is to find the value of n.

If you know N, you can scan from there for the tar file start block.
It contains the filename from byte 0 in the block, up to 100
characters, nul-padded, then some decimal numbers, with space and nul
characters interspersed, then a bunch of nul characters to pad out the
block.  This should suffice to describe the block if you look for it
in, e.g. od dumps or in an emacs buffer.  When you know the offset
into the file, you have the value of n.

Then it's a simple matter of doing:

	dd if=<broken-tar-file> skip=<n> | tar tvf -

Works like a charm.  It may take a while to find the first block of
the first complete file, though.  Searching programs shouldn't be that
hard to write, either, but I don't think anybody has done this, yet.

There is no redundancy in tar files, so if you lose a block, it's
gone.

Hope this helps.

--
[Erik Naggum]		Naggum Software; Gaustadalleen 21; 0371 OSLO; NORWAY
	I disclaim,	<erik at naggum.uu.no>, <enag at ifi.uio.no>
  therefore I post.	+47-295-8622, +47-256-7822, (fax) +47-260-4427



More information about the Comp.unix.misc mailing list