Copying files from an almost failing external drive

There are a number of reasons why an external hard drive may fail at some point. Depending on the reason and how it failed, you may be going for very different recovery methods. In some cases, you can just throw it away and get your latest backup if nothing serious was done in-between. If you had no backup and the drive doesn’t let you copy from it at all, you are in trouble and will need to pay for professional services to recover your data. So, always make backups!

However, the following scenario happened to me recently: a hard drive that I was using to host Virtual Machines started to behave erroneously. I did have a backup of its content, but it was several weeks old and even if it was possible for me to run/download what happened in-between (I didn’t have any real work there, just system and program updates, basically, with a few tricky ones), I did try to recover the content. The fact is that the files were still there, and actually readable. But after some random amount of time copying, the drive would go offline for some time and come up again, as if it was overheating. Most file copying software I used weren’t able to recover after the drive had gone offline, even though it was just a matter of keeping the parts that had already been copied and then resume where it had stopped.

So I created a little program that I’m pushing on github for anyone else who would experience the same problem: https://github.com/prismsoul/safecopy

The principle is fairly simple: copy from an unreliable source to a safe destination. Whenever the source becomes unavailable, the program stops and waits some seconds in a loop to try to read the file again where it had stopped. It did happen that once the drive didn’t come up again on its own, so I had to power it off and on again, and it came back online, the program managed to open the file again and continued with the copy. And the files I recovered seem to be working fine and will avoid me some unnecessary time upgrading and downloading the VMs.

Here is a typical output when the drive fails:

Copying C:\vms\WalletsUbuntu\WalletsUbuntuWallets-disk2.vmdk to Y:\vms\WalletsUbuntu2\WalletsUbuntuWallets-disk2.vmdk
0..Could not read... at position 9999679488 waiting and retry
Could not find file... waiting...
.......1...Could not read... at position 43075502080 waiting and retry
Could not find file... waiting...
.....Could not read... at position 56550293504 waiting and retry
Could not find file... waiting...
.Could not read... at position 59379154944 waiting and retry
Could not find file... waiting...
2....Could not read... at position 75804770304 waiting and retry
Could not find file... waiting...
.....3.Could not read... at position 95922946048 waiting and retry
Could not find file... waiting...
.Could not read... at position 99697754112 waiting and retry
Could not find file... waiting...
Could not find file... waiting...
Could not read... at position 100172169216 waiting and retry
Could not find file... waiting...
....
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s