I accidentally deleted the home directory on my Amazon Linux EC2. My whole site disappeared. What now?

0

I was using sudo rm -rf to delete some folders, and accidentally deleted the /Users/ec2-user home directory. I had my EC2 and AWS Route 53 running my site. Now, it just disappeared. I have all the files for my website, but don't know how to get it back up and running well. It just says "No Data Received" if I visit my website. Help!

crownusa

Posted 2014-01-28T21:24:25.077

Reputation: 15

8You restore your website from the backup you did. Amazon might be able to help also. – Ramhound – 2014-01-28T21:27:31.323

1Two words: Restore. Backup. I don't know of AWS/EC2 keeps snapshots, if they do, rolling back to the last snapshot would do it. – Ricky Beam – 2014-01-28T21:28:45.800

I have the files for the website (all the html/css/js). So I just place it right in a new ~/ folder? – crownusa – 2014-01-28T21:34:44.670

First, try creating /Users/ec2-user and then copying the files back. – terdon – 2014-01-28T21:38:39.797

2Follow the same procedures you used to create the site originally – Ramhound – 2014-01-28T21:51:37.397

Well, I can't even ssh/connect to my EC2, because the /home/<username>/.ssh/authorizedkeys file was deleted (see this article). I keep getting the Permission denied (publickey) error. Can I reset the EC2 to factory settings somehow? That might help.

– crownusa – 2014-01-28T21:52:14.977

This is the problem with making backups and not testing them. It's not until an emergency that you find out that you can't actually restore your site from your backups. – David Schwartz – 2014-01-28T23:12:59.447

Answers

1

If you have taken an AMI of your instance or an EBS snapshot, you can launch a new instance from it. Otherwise, if you have all your important files somewhere else, you can launch a fresh stock instance and redo the setup you did originally. Then just reassign the Elastic IP of the old instance to the new instance, and terminate the old one.

David Levesque

Posted 2014-01-28T21:24:25.077

Reputation: 521

1This. Make a new server and try not to break this one so carelessly. – Xyon – 2014-01-29T12:56:29.407