Copy single file with I/O errors

I would like to copy a file from one disk (HDD with filesystem NTFS) to another (SSD with ExFAT, if it matters).
The problem occurs in the middle of the copy process, showing me the following message: The Finder can't complete the operation because some data in "File.data" can't be read or written. (Error code -36)

The Finder can't complete the operation because some data in "File.data" can't be read or written. (Error code -36)

I have tried to use cp, rsync and dd without any luck.

The rsync command (with --ignore-errors flag) throws me the following error:

rsync: read errors mapping "/Volumes/HDD/File.data": Input/output error (5)
rsync: read errors mapping "/Volumes/HDD/File.data": Input/output error (5)
ERROR: File.data failed verification -- update discarded.
rsync error: some files could not be transferred (code 23) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-51/rsync/main.c(996) [sender=2.6.9]

dd just copied a partial data (the part before the problematic sector, without skipping it).

Any ideas how to copy this damn file?


Solution 1:

Aside from dd there is also ddrescue although it's not a native OS X/macOS utility, however it can be installed in a number of ways. Personally I prefer to compile directly from source code however Package Managers like Homebrew can be used, or a precompiled binary if one is comfortable accepting a precompiled binary from an non-authoritative source.

Note that to compile from source code or use a package manager you need to have Command Line Tools for Xcode installed. You do not need to have the full Xcode installed, just the Command Line Developer Tools which are only a couple hundred megabyte vs many gigabytes.

The Command Line Tools for Xcode install can be started from Terminal with the following command:

xcode-select --install

To use ddrescue read its manual page, man ddrescue in Terminal, or online: GNU ddrescue Manual