ddrescue is a GNU provided data recovery tool.It can copy and recover file, directory or whole hard drive. The best part of the
ddrescue is it can prevent or solve read errors.
Install For Ubuntu, Debian, Kali and Mint
We can install
ddrescue tool for
deb based distributions like below.
ddrescue command is provided with package name
$ sudo apt install gddrescue
List Hard Drives
Before rescuing or copying files and directories we generally need to list hard drives so we will be sure that which is the source and which is the destination drive with its path. We will list drives with
$ sudo fdisk -l
Copy Single File
We will start with a simple copying file example we will copy file named
Data. This option do not needs any option.
$ ddrescue Data /home/ismail/backup/Data
As we can see there is a lot of information about the single file copy and rescue operation. One of the most important output is that the
Finished which means it is successfully finished copying file.
Copy Single Directory
We can also copy a directory with the same syntax as file. We will copy directory named backup to the
/mnt/ where we have mounted our tape.
$ ddrescue backup /mnt/backup
Save Log to File
During the copy and backup operation some logs are created for troubleshoot or review. By default these logs are not created but we can save these logs into a file. We will add the log file path and name after source and destination. In this example we will write log file current working directory as
$ ddrescue Data /home/ismail/backup/Data ddrescue.log
Set Maximum Read Rate or Speed
While copying or backup we may need to set some maximumu for read operating because of the operational issues. We can set maximum speed for read operation from source. We will use
--max-read-rate=. In this example we will set 10 megabyte.
$ ddrescue -Z 10M Data /home/ismail/backup/Data