A few weeks ago I was reading a Article of Elav on backups and it fell like a glove, as I was recovering from the accidental loss of my / home.
A victim of sleep and stress, I made a mistake and my data was deleted, I went into panic and despair. After assimilating it I remembered a tool called Get out.
extundelete is an excellent tool, which allows you to recover deleted data on ext3 and ext4 partitions.
Some of its characteristics:
Ability to preserve the original name of the recovered files, it can recover partitions, directories and subdirectories, among others.
Let's go to what interests us.
When accidentally deleting a file, directory or partition, you should immediately shut down your computer or unmount the partition.
This to prevent new data from being written to the physical space of the disk, if this happens, the possibility of recovery decreases.
If possible, start from a Live CD or USB of your favorite distribution and install Extundelete.
To install on Debian and derivatives:
sudo apt-get install extundelete
Next we mount the partition where our files were located, in read mode (suppose that the sda4 partition is our home).
sudo mount -o remount,ro /dev/sda4
If we want to restore the entire partition:
sudo extundelete /dev/sda4 --restore-all
If we want to restore a specific directory (for example the folder "documents"):
sudo extundelete /dev/sda4 --restore-directory /home/tu_usuario/documentos
If we want to restore a specific file (for example the video gato.flv):
sudo extundelete /dev/sda4 --restore-file /home/tu_usuario/videos/gato.flv
If you do not know the name of the partitions that interest you, write in the console:
sudo fdisk -l
extundelete It has a large number of options that you can explore on its page, but with the above, you are sure to get out of trouble. I was able to recover maybe 90% - 95% of my partition.