Recently one of the hard drives in my Linux server failed. I did have a backup but it wasn’t as recent as I’d like and didn’t include some recent emails that I wanted to keep (it’s my main email machine – I did have copies of the emails on my laptop but merging them with the server backup would have been a bit tricky).
At first the filesystems on the failed disk wouldn’t even mount, so I ordered some new drives and resigned my self to restoring from the backup. When the new drives arrived I decided to have one last go at copying my files from the failed drive… and this time the filesystems would mount! Unfortunately the faulty drive wouldn’t talk to my computer for long enough to copy the data off (part way through the copy it would stop responding to the computer and I would have to power-cycle the computer for it to be able to see the disk again).
At this point I had a look on the internet for tools that might help me recover my data and eventually found ddrescue. ddrescue is a clever tool that can copy data from one disk to another, skipping over areas that it can’t read. It logs which areas it couldn’t read, so that it can retry just those areas without having to read the whole disk again. I also read about the “freezer trick” – apparently some failing hard drives will work again briefly after being in a freezer (inside a watertight bag) for a few hours).
So, I ran ddrescue and it managed to read most of my drive. I then froze the drive for about 8 hours and ran ddrescue again. It was able to read some of the previously-unreadable areas, but I’m not sure whether this was because the drive was frozen or not. Anyway, in the end there was only about 10KB of 400GB unreadable, so I was pretty happy.
The next thing I did was improve my backup regime 😉 My server now has 2 drives mirrored using RAID 1, and a 3rd drive that is synchronised with the main drives every night.