{"id":1317,"date":"2021-07-09T20:32:26","date_gmt":"2021-07-09T20:32:26","guid":{"rendered":"https:\/\/www.antpace.com\/blog\/?p=1317"},"modified":"2025-08-25T17:52:01","modified_gmt":"2025-08-25T17:52:01","slug":"restoring-a-website-when-ec2-fails","status":"publish","type":"post","link":"https:\/\/www.antpace.com\/blog\/restoring-a-website-when-ec2-fails\/","title":{"rendered":"Restoring a website when EC2 fails"},"content":{"rendered":"<p>Recently, one of my websites went down. After noticing, I checked my EC2 dashboard and saw the instance stopped. AWS had emailed me to say that due to a physical hardware issue, it was terminated. When an instance is terminated, all of its data is lost. Luckily, all of my data is backed up automatically every night.<\/p>\n<p>Since I don&#8217;t use RDS, I have to manually manage data redundancy. After a few disasters, <a href=\"https:\/\/www.antpace.com\/blog\/automatic-mysql-dump-to-s3\/\" target=\"_blank\" rel=\"noopener\">I came up with a solution to handle it<\/a>. I trigger a nightly cron-job to run a shell script. That script takes a MySQL dump and uploads it to S3.<\/p>\n<p>As long as I have the user generated data, everything else is replaceable.\u00a0 The website that went down is a <a href=\"https:\/\/www.antpace.com\/blog\/bjj-tracker\/\" target=\"_blank\" rel=\"noopener\">fitness tracking app<\/a>. Every day users record their martial arts progress. Below are the ten steps taken to bring everything back up.<\/p>\n<ol>\n<li>Launch <a href=\"https:\/\/www.antpace.com\/blog\/website-on-aws\/\" target=\"_blank\" rel=\"noopener\">a new EC2 instance<\/a><\/li>\n<li>Configure the security group for that instance &#8211;\u00a0 I can just use the existing one<\/li>\n<li>Install Apache and MariaDB<\/li>\n<li>Secure the database<\/li>\n<li>Install PhpMyAdmin &#8211; I use this tool to import the .sql file in the next step<\/li>\n<li>Import the database backup &#8211; I downloaded the nightly .sql file dump from my S3 repo<\/li>\n<li>Setup <a href=\"https:\/\/www.antpace.com\/blog\/automatic-mysql-dump-to-s3\/\" target=\"_blank\" rel=\"noopener\">automatic backups<\/a>, again<\/li>\n<li>Install <a href=\"https:\/\/www.antpace.com\/blog\/migrate-a-wordpress-site-to-aws\/\" target=\"_blank\" rel=\"noopener\">WordPress and restore the site&#8217;s blog<\/a><\/li>\n<li>Configure Route 53 (domain name) <a href=\"https:\/\/www.antpace.com\/blog\/secure-a-website-with-ssl-and-https-on-aws\/\" target=\"_blank\" rel=\"noopener\">and SSL (https)<\/a> &#8211; make the website live again<\/li>\n<li>Quality Assurance &#8211; &#8220;smoke test&#8221; everything to make sure it all looks correct<\/li>\n<\/ol>\n<p>Use this as a checklist to make sure you don&#8217;t forget any steps. Read through the blog posts that I hyperlinked to get more details.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, one of my websites went down. After noticing, I checked my EC2 dashboard and saw the instance stopped. AWS had emailed me to say that due to a physical hardware issue, it was terminated. When an instance is terminated, all of its data is lost. Luckily, all of my data is backed up automatically &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.antpace.com\/blog\/restoring-a-website-when-ec2-fails\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Restoring a website when EC2 fails&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3225,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[12,24,36,92,111],"class_list":["post-1317","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development","tag-aws","tag-cloud-computing","tag-database","tag-php","tag-s3"],"_links":{"self":[{"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/posts\/1317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/comments?post=1317"}],"version-history":[{"count":1,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/posts\/1317\/revisions"}],"predecessor-version":[{"id":3226,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/posts\/1317\/revisions\/3226"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/media\/3225"}],"wp:attachment":[{"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/media?parent=1317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/categories?post=1317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/tags?post=1317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}