You’ve developed your app, you’ve deployed it to your EC2 server, you’ve configured the SSL because HTTPS is the only way to serve websites in 2017, and you’ve got your database all setup on RDS. You’re just starting out, so you don’t have a lot of complexity to your site. Everything is good.
But what if the EC2 instance were to fail or need a rollback?
If it were 2016, you’d be writing a script right now to automate the snapshots, because backups are good! Luckily, it’s not 2016, and there’s a simple service to allow you to schedule your EBS snapshots for you! This service is the CloudWatch Events service.
Sure, the fact that you go to the CloudWatch console to perform an automatic EBS backup sounds a little strange. It would make more sense for this to be in the EC2 console, but I digress. The main takeaway here is that it is much easier to create a CloudWatch event than it is to script your backups manually. So let’s go through the straightforward process of setting one of these bad boys up!
Snapshotting data the easy way with Cloudwatch Events
First, head on over to the EC2 console and obtain the “EBS Volume ID”. In this example, I’ll be backing up the “/dev/sdb” volume since it’s my data volume. I have added a separate volume to make expanding and upgrading my instance easier without affecting the data:
Once you click on that, you are greeted with more information about the volume. The information you want is boxed in red:
Ok, great! Now that you have that, let’s go schedule those snapshots! Head back to the CloudWatch console, choose “Events” on the side, and click Create rule:
Once you have done that, you are greeted with the Create rule screen. I want to snapshot my EBS volume once a day, so choose the “Schedule” radio button, then the “Fixed rate” radio button, and finally enter “24 Hours” as the rate. Once this is done, it’s time to select the target. To do this, select “EC2 CreateSnapshot API call” from the drop down and paste the “Volume ID” you retrieved from the EC2 console, then click Configure details:
Notice how many options there are in the “Targets” dropdown. You can accomplish a lot just from this console. It has certainly made administration and maintenance tasks much simpler!
Ok, after you have clicked Configure details, you are greeted with the final screen in the process. In the “Configure rule details” screen, create a name, a description, enable or disable it, and select your role. Luckily, the CloudWatch Events service already has roles preconfigured for the operations it offers. In most cases, you will select the “AWS_Events_Actions_Execution” role and click Allow on the screen that follows. Once you have done this, you will be brought back to the “Configure rule details” screen. Once everything is configured, go ahead and click Create rule!
If there was no error, you should see the following screen:
Congratulations, you are now snapshotting your EBS volume once a day and you can hopefully focus your sleepless nights on development rather than worrying about your data volume disappearing into thin air! Go forth and conquer!
Comments
0 comments
Please sign in to leave a comment.