Recovering data from a corrupted partition

Assume /dev/sdb7 ( say the old home partition ) is the dead partition from
which we want to recover data. This is the case where old /home partition
is corrupted so that it can no more be mounted or rsynced.

ddrescue -- tool to recover data from a dead disk

1. Download and install ddrescue on the server.

wget http://ftp.gnu.org/gnu/ddrescue/ddrescue-1.3.tar.bz2
tar xjf ddrescue-1.3.tar.bz2
cd ddrescue-1.3
./configure
make
make install

2. Make sure /dev/sdb7 is not mounted and then run ddrescue to create a
disk image of it. Current /home should have enough space to hold the
backup.img file. It will be at least twice as big as the old home
partitions used disk space.

ddrescue /dev/sdb7 /home/backup.img

3. Once the image is created run fsck on it.

fsck -r -y /home/backup.img

4. Now mount the image on to the file system. Make sure to use '-o loop'
option with mount command as you are mounting a disk image, not a
physical partition.

mkdir /old-home
mount -o loop /home/backup.img /old-home/

5. Now you can find all data on the dead home partion under /old-home.

6. Now run the rsync command to get the files from old home partition.
rsync -vrplogDtH /old-home/* /home