24

I need to copy several Gb from an external HD to my main HD and some files will cause errors. If I do this with the finder, it will stop on the first error.

Is there a way to copy everything no matter the errors? Something like copy of Teracopy for Windows?

Dave M
  • 13,250
cfischer
  • 9,163

4 Answers4

29

In terminal, type in

cp -Rp /Volumes/<source-volume>/<source-user>/<source-folder>/ /Volumes/<destination-volume>/<destination-folder>/

Destination folder should be a new folder you are creating.

If you get info on the new folder after running this you can see the folder size increase.

Example

cp -Rp /Volumes/Macintosh HD/User/Bob/Desktop/stufftocopy/ /Volumes/external/newfolder

It will copy and display errors for anything it can't copy but without stopping.

*If your directory names contain spaces put quotes around the path

Example

cp -Rp "/Volumes/Macintosh HD/User/Bob/Desktop/stufftocopy/" /Volumes/external/newfolder

Explanation:

run "man cp" to see command description and all options man cp

As of Mac OSX 14.6.1 (23G93) the "-Rp" arguments mean:

-R:

     -R    If source_file designates a directory, cp copies the directory and the entire subtree connected at that
       point.  If the source_file ends in a /, the contents of the directory are copied rather than the
       directory itself.  This option also causes symbolic links to be copied, rather than indirected through,
       and for cp to create special files rather than copying them as normal files.  Created directories have
       the same mode as the corresponding source directory, unmodified by the process' umask.
   In -R mode, cp will continue copying even if errors are detected.

   Note that cp copies hard linked files as separate files.  If you need to preserve hard links, consider
   using tar(1), cpio(1), or pax(1) instead.

-p:

     -p    Cause cp to preserve the following attributes of each source file in the copy: modification time,
       access time, file flags, file mode, user ID, and group ID, as allowed by permissions.  Access Control
       Lists (ACLs) and Extended Attributes (EAs), including resource forks, will also be preserved.
   If the user ID and group ID cannot be preserved, no error message is displayed and the exit value is
   not altered.

   If the source file has its set-user-ID bit on and the user ID cannot be preserved, the set-user-ID bit
   is not preserved in the copy's permissions.  If the source file has its set-group-ID bit on and the
   group ID cannot be preserved, the set-group-ID bit is not preserved in the copy's permissions.  If the
   source file has both its set-user-ID and set-group-ID bits on, and either the user ID or group ID
   cannot be preserved, neither the set-user-ID nor set-group-ID bits are preserved in the copy's
   permissions.

5

You can use cp as suggested or rsync, but in the case of I/O Error sometimes it won't work.

So in this case, you can use dd tool for specific files which were corrupted.

dd stands for “disk duplication”. This is a command-line utility bundled with Mac OS X. A free version for Windows is also available.

Be extremely careful, even if you are familiar with command line, because dd can cause unrecoverable damage to your data if you don’t specify correctly input and output. You have been warned.

The arguments of dd are straight-forward:

  • if=path_of_file_with_IO_errors specifies input path
  • of=path_of_clean_copy_to_create specifies output path
  • conv=noerror,sync tells dd to be fault-tolerant

Your output path should not be on the same disk as the damaged file. Actually, you shouldn’t continue using the card or disk with I/O errors, because it’s likely to cause more problems in the future. After recovery the data, you should scrap it or at most use it to store unimportant stuff.

Due to I/O errors, dd can take more time to create the clean copy than a normal copy would take.

But it’s really worth the wait, because now we have a clean file on which we can use our arsenal of diagnostics, preview and video recovery tools.

I/O errors are a serious business, and scrapping the card after recovering the videos is probably the RIGHT THING TO DO. You should also consider that some amount of footage won’t be recovered, or with a less-than-stellar quality.

Source: http://aeroquartet.com/wordpress/2012/06/06/how-to-copy-a-file-with-io-errors/

Example:

dd if=/Volumes/CD/broken_movie.avi of=~/Movies/broken_movie.avi conv=noerror,sync

See also:

kenorb
  • 26,615
3

I use Beyond Compare for exactly this purpose (it's commercial software but has a free trial). You tell it to copy a file, a folder, or a whole drive or any combination and it finishes to the end of the task and reports problems as it goes. This doesn't help recover any corrupted files, but it will finish the job no matter how many problems it encounters.

fixer1234
  • 28,064
Tim D
  • 31
2

Teracopy has released a Mac version which you can download from the Apple store.

mcwizard
  • 123