23. June 2013 2 min read
Undelete files from ext3 or ext4 Linux command line
It happens to everybody. You are moving, copying, arranging files and in command line you just write that pesky rm -f and lose half of what you did not even want to. Then you start thinking about that early computer class where they told you nothing on disk is really lost, but it is just put -out of reach-. So, I will show you how to restore a deleted file, or if you prefer how to undelete a deleted file on ext3 or ext4 disk - using Linux of course.
To give restoration at least a fighting chance you should stop any writing processes on that hard-drive.
This will sound very promising, but I must remind you that by installing a new program (extundelete) you might just overwrite the file you deleted. So if you are just setting up your server or computer it is wise to get that extundelete installed before you start using it. Anyway not to be too long. To restore files you simply type:
extundelete --restore-file file_to_restore /dev/mount_partition
# Be aware that you need a relative path to file (so no /tralala/file.c)
# and that you need mount_partition like /dev/sda3
extundelete --restore-directory path/to/directory/ /dev/mount_partition
# this command is to restore a directory
Extundelete has many other features to undelete all files, to restore files --after 'deletetime' or --before 'deletetime' but above cases should be enough to do the trick in most times.