Is there a terminal command to copy all files on a damaged external drive to a new external drive?
I have a damaged hard drive (external WD 4TB Passport). I've tried using CCC and the finder to copy the files over to a new drive now that I have managed to mount it(unsuccessfully). I was thinking using the terminal (copying block by block instead of each file?) might accomplish the desired outcome of having the usable data on a working drive, but I'm not sure if my thought process is correct, or if this is possible.
Block by Block copy would be the 'dd' command (man dd).
dd if=/Volumes/damaged_external of=/Volumes/good_external bs=262144 conv=noerror
The bs=262144 is the read/write size of 256K. you can play with that if you like. If you have individual damaged sectors you might lose 256K if just one 512byte sector is bad in that range. But trying to copy 4TB in 512-byte chunks will take forever. As it is copying in 256K chunks will take awhile.
NOTE: If the file system is corrupt, that is to say, the file system metadata is "out of whack" but the disk blocks holding that data is good, then you will just be putting the broken file system on the other external drive. But if the problem is the disk drive, if the dd works, and all the file system metadata makes it over, then you might have a working file system.
rsync approach - this would be a File by File copy.
Here is an article on using rsync to create a bootable clone of your boot disk. If you modify the instructions so that you point the source at your damaged_external and the destination at the good_external, it should work just as well. http://nicolasgallagher.com/mac-osx-bootable-backup-drive-with-rsync
ditto approach - There is the ditto command (man ditto)
Here is an article on using ditto to copy files http://osxdaily.com/2014/06/11/use-ditto-copy-files-directories-mac-command-line/