Unrar Switch to Keep Files After an Error

This guide explains how the unrar utility handles errors during extraction and highlights the specific switches used to manage corrupted archives. While the unrar tool inherently leaves the original .rar archive file intact by default, it automatically deletes partially extracted files upon encountering an error unless the -kb (Keep Broken) switch is specified.

Archive Safety by Default

When extracting archives using the command-line utility unrar, the source .rar archive is opened in a read-only state. Regardless of CRC errors, truncated volumes, or corruption during the extraction process, unrar will never delete, truncate, or modify your original archive file. The source archive remains untouched on your disk.

The -kb Switch: Preserving Extracted Files

Although the source archive remains safe, unrar's default behavior is to delete any extracted files that fail a CRC (Cyclic Redundancy Check) or encounter read errors.

To prevent unrar from deleting damaged or incomplete files from your destination folder, use the -kb (Keep Broken) switch.

Syntax

unrar x -kb archive.rar

or for extracting without directory paths:

unrar e -kb archive.rar

How the -kb Switch Works

  • Default Behavior (Without -kb): If an error occurs midway through unpacking a file, unrar halts or continues to the next file while automatically purging the damaged file from your storage drive to avoid leaving corrupted data behind.
  • Behavior with -kb: If an extraction error occurs, unrar displays the error message but leaves the partially or incorrectly unpacked file in the destination directory.

Practical Use Cases for -kb

  1. Multimedia Recovery: Incomplete video, audio, or text files can often still be partially read, played, or repaired by media players such as VLC, even if the end of the file is missing or corrupted.
  2. Data Forensics and Inspection: When inspecting corrupted archives, having access to whatever partial data was recovered can assist in diagnosing where the archive failed or recovering salvageable text and assets.
  3. Multi-Part Archives: If a multi-volume archive is missing the final volume, -kb allows you to keep all files extracted up to the point of the missing part.