0

This morning while I was doing a bit of work on my production server, when I accidentally executed the following command:

sudo rm -r /*

Sadly, the server no longer accept my public key or password for any user via SSH.

And files were hosted on /home directory instead of /var/www is there any way to restore the files?

And after this incident happen I took AWS Snapshot of AWS EC2. Then Relaunch it by taking new server.

Although I lost the all my files and project. But I discovered that I still have database. As I've also hosted another application under /var/www directory it seems to running fine.

Would it possible to recover the mysql database from Secondary Image on server?

I tried running executing previous mysql_user and mysql_password on my new server it is not authenticating.

Maqsud
  • 111
  • 2
  • 4
    Achievement unlocked. Congrats. Unlock the next by successfully applying the backups, or an alternate, called "Learned the need of backing up the whole thing". – drookie May 04 '21 at 06:54
  • 1
    Is there a question you have? In other words, what kind of advice do you expect? If you want a way to log in, have you considered logging in at the console, or perhaps booting into single-user mode? After that, it should be easy to fix the login problem and restore the backup. For more focused advice, provide context: What operating system, what server, what options there are to access it etc. – berndbausch May 04 '21 at 07:08
  • Is there any way to undo the following? – Maqsud May 04 '21 at 07:09
  • 1
    Undo what precisely? If you want to go back to the moment before you executed the command, no. However, you can restore a backup, which should come close. If you want something else, say it. – berndbausch May 04 '21 at 07:10
  • 4
    Does this answer your question? [Monday morning mistake: sudo rm -rf --no-preserve-root /](https://serverfault.com/questions/587102/monday-morning-mistake-sudo-rm-rf-no-preserve-root) – Bob May 04 '21 at 07:12
  • I've just created Snapshot. Will it be possible to restore the files using resuce-mode – Maqsud May 04 '21 at 07:15
  • 1
    Hopefully you're on a reasonably modern Linux distribution with a `rm` binary that treats the '/' differently (that by default uses `--preserve-root`) and there's nothing to worry https://www.gnu.org/software/coreutils/manual/html_node/Treating-_002f-specially.html#Treating-_002f-specially – Bob May 04 '21 at 07:17
  • 2
    @Bob nope: command was including `/*` that means the actual parameters were `/bin /boot /dev /etc` ... once expanded. – A.B May 04 '21 at 22:54

0 Answers0