Recovery

How archive repair tools actually work

Recovery records, local-header scanning and external parity all attack the same problem differently. Knowing which redundancy an archive carries tells you what is recoverable.

Files Corrupter ·

How archive repair tools actually work

“Repair archive” is a button in several tools and it means something different in each of them. The difference is worth understanding, because it decides whether a damaged archive is a minor inconvenience or a total loss.

Redundancy is the only thing that repairs anything

No tool can invent missing data. Repair works only where redundancy exists, which comes in three forms:

  1. Structural redundancy, where the same information appears twice.
  2. Error-correcting redundancy, deliberately added parity.
  3. External redundancy, a separate copy or parity file.

Each archive format offers a different mix.

ZIP: structural redundancy, by accident

A ZIP archive stores each entry’s metadata twice. Once in the local file header immediately before the compressed data, and again in the central directory at the end. The directory is what tools read, because it lists everything in one place with byte offsets.

When the central directory is damaged, repair tools fall back to scanning the file from the beginning for the PK\x03\x04 local header signature. Every hit gives a filename, a compression method and a size, which is enough to rebuild a directory and extract most entries.

This works remarkably well, and it is exactly why damaging only the end of a ZIP achieves very little. It is also why the ZIP corrupter destroys the local headers as well as the directory. The same reasoning applies to Office documents, which are ZIP packages underneath, as covered in why flipping random bytes does not corrupt a DOCX.

RAR: deliberate error correction

RAR is the format that took corruption seriously. It offers an optional recovery record, extra parity data stored inside the archive, sized as a percentage of the content. If part of the archive is damaged, WinRAR can reconstruct the missing bytes from the parity, genuinely repairing rather than salvaging.

There are also recovery volumes, .rev files that sit alongside a multipart archive and can rebuild a missing part entirely.

The catch is that both are opt-in and both live with the data they protect. A recovery record survives a few bad sectors. It does not survive the archive being deliberately overwritten, which is why the RAR corrupter scatters entropy through the body rather than only touching the header.

7z: fast, small, and unforgiving

7-Zip has no recovery record. Its metadata lives in a compressed header at the end of the file, reached through an offset in a small header at the start. Damage either end and the archive has no map of itself, and there is no parity to rebuild from.

That makes 7z excellent for distribution and a poor choice for long-term archival on unreliable media, unless you pair it with external parity.

TAR: no index at all, which turns out to help

TAR has no central index whatsoever. Each file is preceded by its own 512-byte header containing the name, size, mode and a checksum. Extraction is a linear walk: read a header, skip forward by the size it declares, read the next one.

That makes TAR the most recoverable archive format in common use. Lose the middle and tar can often resynchronise on a later header and continue. It is the reason .tar.gz is a slightly odd pairing: gzip is a single stream, so damage early in the compressed data usually loses everything after it, throwing away the very property that made TAR robust.

PAR2: external parity, format-agnostic

Where the archive format offers nothing, PAR2 adds Reed-Solomon parity in separate files. It works on any data, and it repairs by block rather than by file. Ten percent parity survives ten percent damage, wherever that damage falls.

It remains the right answer for cold archives on optical media or anything you will not touch for a decade. The related idea, verifying rather than assuming, is the subject of your backup is a hypothesis until you restore it.

What this means in practice

FormatRedundancySurvives
ZIPDuplicated headersLoss of the central directory
RAROptional recovery recordBounded random damage
7zNoneVery little
TARPer-file headersLoss of arbitrary regions
Any + PAR2External parityDamage up to the parity ratio

If you want to see how each behaves under controlled damage, make an unopenable archive in each format and try your usual repair tool on it. The results are more instructive than any table.