2

The story:
I am using Ubuntu for my website.
For a backup plan, I wrote a script. I wanted to mount an external drive, (run through crontab), backup the server, and then umount it, every night. I noticed that through fdisk -l I got:

/dev/sda
/dev/sdb

To be sure, I ejected the external drive, and saw this:

/dev/sda

I assumed /dev/sda was my server's disk.
I then plugged in the external. Created a directory in /mnt/GBackup_plan mounted it:

mount /dev/sdb1 /mnt/GBackup_plan

Then it happened.
I wanted the external to be clean...
I then run the command:
rm -r *
I did it all inside GNOME, and I started to see the environment starting to lose stability, and only then I realized that I did a horrible horrible mistake, although I still don't know why... (sdb was the external, no?!)
Because of this mistake it so happened that all my backups, everything was actually NOT in the external, but on the original disk...

So turns out I erased the root of my server!!!
I ran Hiren's Boot CD, using TestDisk, and examining the filesystem, I can see the Root of the filesystem, but when I go into the folders they are empty. Perhaps I should do another step before listing/copying? Analyse maybe?

I am wish someone has an idea of what I should do.
I should say that I stopped the command using ctrl+c and turned off the computer. Took the disk out.

Any help would be appreciated!!!

1
  • 3
    It is unlikely that you can easily recover from this. I hope you had some basic manual backup already!
    – mattdm
    Jul 24, 2014 at 21:52

1 Answer 1

1

There is a good chance that your data may not be recoverable. However, Ubuntu actually provides a data recovery guide for situations such as yours. The article goes into significant detail, but this is the general idea:

Make an image of your disk

This is critical. You want to make an exact bit-to-bit copy of your disk to work on; if the recovery goes sideways on an image, you lose the image - create another. When working on the disk, a mistake is final. I actually recommend making the image, copying it, and working on the copy.

Triage

Find out how bad it is. The guide recommends sleuthkit/autopsy. I have no better recommendations. Hiren's tools are likely sufficient.

Recover

Start the recovery process. According to this pretty definitive article if you're lucky, you might be able to recover it all at once. If you're kinda lucky, you can recover files individually. If you really aren't lucky, then... yeah.

Next Time

  • Never run rm with wildcards as root without specifying an absolute path.
  • Never run rm with wildcards as root without a current backup.
  • Always check your pwd
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .