Protecting archives from damage

WinRAR

Protecting archives from damage


RAR archive format supports a special type of redundant data called the recovery record. Presence of recovery record makes an archive larger, but allows to repair it even in case of physical data damage due to disk failure or data loss of any other kind, provided that the damage is not too severe. Such damage recovery can be done with Repair archive command. ZIP archive format does not support the recovery record.

Set "Add recovery record" option in Archive name and parameters dialog to add the recovery record to archive. Another approach is to enable "Add recovery record" option in the default compression profile. In this case the recovery record will be added to archives after any archive modification.

If you need to add the recovery record in the command line mode, please read descriptions of rr[N] command and -rr[N] switch, which can be used for this purpose.

RAR 5.0 recovery record uses Reed-Solomon error correction codes. Its ability to repair continuous damage is about the same as for RAR 4.x, allowing to restore slightly less data than recovery record size. But it is significantly more efficient than RAR 4.x record in case of multiple damaged areas.

RAR 4.x recovery record consists of 512 byte sectors and cannot contain more than 524288 sectors. So its useful size and data recovery ability are limited to 256 MB. In case of RAR 5.0 format the recovery record can be as large as archive itself.

You can specify the recovery record size in Advanced options of "Archive name and parameters" dialog as a percent of archive size. Also it can be set in Protect archive command. Larger recovery record allows to restore a larger damaged area, but increases the archive size more and is processed slower. Usually 3 - 10% of archive size is a reasonable choice. Due to service data overhead the actual resulting recovery record size only approximately matches the user defined percent and difference is larger for smaller archives.

To repair a corrupt archive, which includes the recovery record, in WinRAR shell mode apply "Repair" command to it. In the command line use command "r". Repaired archive will have fixed.arcname.rar name, where 'arcname' is the original (damaged) archive name. If corrupt archive does not contain the recovery record or if archive is not completely recovered due to major damage, the second stage is performed. During this stage only the archive structure is reconstructed and it is impossible to recover files, which fail checksum validation, but it is still possible to recover undamaged files, which were inaccessible due to corrupt archive structure. This is useful mostly for non-solid archives. This stage is not performed for archives with encrypted file names, which can be repaired only if recovery record is present.

When the second stage is completed, the reconstructed archive will be saved as rebuilt.arcname.rar, where 'arcname' is the original archive name.

RAR 5.0 recovery record is more resistant to damage of recovery record itself and can utilize a partially corrupt recovery record data. Note, though, that "Repair" command does not fix broken blocks in recovery record. Only file data are corrected. After successful archive repair, you may need to create a new recovery record for saved files.

Both 4.x and 5.0 records are most efficient if data positions in damaged archive are not shifted. If you copy an archive from damaged media using some special software and if you have a choice to fill damaged areas with zeroes or to cut out them from copied file, filling with zeroes or any other value is preferable, because it allows to preserve original data positions. Still, even though it is not an optimal mode, both versions of record attempt to repair data even in case of deletions or insertions of reasonable size, when data positions were shifted. RAR 5.0 recovery record handles deletions and insertions more efficiently than RAR 4.x.