Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to recover files from a disk that has hardware errors.

The disk was repaired by disk utility, but it told me that the disk is damaged, so I need to backup everything before a failure will happen.

So I tried to copy the files via finder, but it gets stuck. Tried other utilities and they get stuck trying to copy the files, when the head hits the damaged block.

So I tried with rsync, and it seems to work; but it takes forever when I hit a bad block.

So I was wondering, if there is a way to tell Rsync to not even bother with a file, if it takes too long?Either I can specify the number of try with each file, or how long it needs to try for each file?

I am not sure how long this drive will last honestly, so I want to get all the data off ASAP, while I can still mount it and see the data on it in finder.

This is what I am using as command; please advice if there is any way to reduce the try on a file, so I can have rsync to try to read the damaged blocks, but avoid to get stuck on a specific sector for too long.

rsync -arv -e--ignore-errors --partial-dir=/Volumes/backup/partial /Volumes/work /Volumes/backup

Thanks in advance.

share|improve this question
3  
If the drive has damaged sectors you are better of trying to image the drive with something like dd_rescue, it has advanced features to cope with bad sectors. – jmreicha Apr 17 '13 at 13:46
    
I think @jmreicha has the right idea, but in the future, if you have rsync technical questions, friendly gurus are available on the rsync list: lists.samba.org/mailman/listinfo/rsync – Joe Apr 23 '13 at 22:11

Short answer: rsync it is not the right tool to be used in this case: its use can be even harmful.
Use ddrescue instead (better than dd_rescue). It is able to do what you are asking for.


If the disk is physically damaged, there is the possibility to brick it with any attempt to repair it.

It is not only a question about the use of your time, when rsync seems to hang forever approaching a damaged sector. The problem is that with repeated operations an irreparable failure can happens, and then you will be not anymore able to to rescue your data without expensive parts replacement (always if it will be still possible and you will not have bricked your HDD).

In this case the most safe procedure I found is

  1. To create a raw image on another not broken disk.
  2. To create a copy of that image.
  3. To work on the copy to fix the filesystem and to rescue the files.

Why the copy? Because if it fails something in the filesystem fixing step you can always start again without the need to touch again the original damaged HDD.

I suggest you to use ddrescue, to do the raw disk image, defects included, because it works fine even in case of read errors.


How to do it with ddrescue

You can use ddrescue exactly as you would like to use rsync, skipping the damaged sectors without retrying or splitting them, copying as much data as possible.
This command is here below (instead of /dev/hda1 you will put your device):

ddrescue --no-split /dev/hda1 imagefile logfile

After that you have done this first passage (the faster one), you can try to refine it trying to access for 3 times in case of error.

ddrescue --direct --max-retries=3 /dev/hda1 imagefile logfile 

You can continue to refine the image repeating the ddrescue command invocations with other options, trying each time to extract more data (see the references). When you will finish you can create the copy (if you have all the needed space) and then to fix the filesystem.

Note that the raw image will be as big as the original HDD.
You can find on internet, on this and on other sites of StackExchange many questions&answers about how to rescue data with ddrescue or other tools.

References:

share|improve this answer
    
indeed dd_rescue is the way to go. I had it in my original reply, 2 years ago; but for some reasons someone decided that I could not answer my own question :) Thanks for the reply and awesome details – newbiez Oct 6 '15 at 23:16
    
@newbiez: Instead I had a serious disk problem with my almost bricked main HDD... so I met ddrescue and its friends :-) About your answer only a word: weird... post it again and if someone will try to close again I will vote yes to reopen (I never used that new power :D) – Hastur Oct 7 '15 at 7:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.