Recovering deleted files

Today I accidentally deleted all files in my /home/Documents directory and had to recover some of them.
Luckily, there’s an easy way with the extundelete program.

First of all, umount the target partition:
sudo umount /home

Note: if you get the ‘device is busy’ message, you can add the lazy option:
sudo umount -l /home

Then install extundelete (if you don’t have it already):
sudo apt-get install extundelete

Now recover the files that were deleted from that directory, for which you need to specify the mount point (use df -h for that):
sudo extundelete --restore-directory /home/Documents /dev/sda5

This will create a RECOVERED_FILES directory with all the file structure of the deleted directory, containing the files that could be restored.

Finally remount the target partition:
sudo mount -o remount,rw /dev/sda5 /home

That’s it!


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s