Hard disk or CD with important information gone bad? You might still be able to recover readable data using the low-level rescue tool safecopy. It’s a utility similar to GNU ddrescue.

safecopy does not fail where other tools (like cat or cp) fail on encountering an I/O error. It uses low level IO to read media in raw mode as well as direct hardware access with O_DIRECT instead of making calls through the virtual filesystem. In addition it issues device resets and other helpful low level operations.

Users can force continue a previous safecopy run at arbitrary position. It can keep trying to open source files even when they went away. This allows copying from devices that vanish temporarily in case of errors, like USB drives that renumerate in case of device resets.

From the developer notes: internally safecopy does this by identifying and skipping problematic or damaged areas, and continuing reading afterwards. The corresponding area in the destination file is either skipped (on initial creation that means padded with zeros) or deliberately filled with a recognizable pattern to later find affected files on a corrupted device. safecopy uses an incremental algorithm to identify the exact beginning and end of bad areas, allowing the user to trade minimum accesses to bad areas for thorough data resurrection. Multiple passes over the same file are possible, to first retrieve as much data from a device as possible with minimum harm, and then trying to retrieve some of the remaining data with increasingly aggressive read attempts.

safecopy can generate data to simulate a corrupt media. This data can be used to benchmark safecopy against similar data recovery tools.

Installation

To install safecopy on Ubuntu:

$ sudo apt-get install safecopy

Usage

A few common use cases:

To view the options safecopy provides, run: $ safecopy --help

Resurrect a file from a mounted but damaged media, that cp failed on: $ safecopy /path/to/problemfile ~/saved-file

Create a filesystem image of a damaged disk/cdrom: $ safecopy /dev/device ~/diskimage

Interrupt and later resume a data rescue operation: $ safecopy source dest <CTRL+C> (safecopy aborts) $ safecopy source dest -I /dev/null

F ind the corrupted files on a partially successful rescued file system: $ safecopy /dev/filesystem image -M CoRrUpTeD $ fsck image $ mount -o loop image /mnt/mountpoint $ grep -R /mnt/mountpoint "CoRrUpTeD"

ind the corrupted files on a partially successful rescued file system: Create an image of a device that starts at X and is Y in size: $ safecopy /dev/filesystem -b -s <X/bsize> -l <Y/bsize>

Webpage: safecopy