Hey, you! Yes, you, the one who thought of everything. You developed your app, you deployed it to your EC2 server, you configured the SSL, and you 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 looking good!

But what if the EC2 instance were to fail or need a rollback?

If it were 2016, you would be writing a script right now to automate the snapshots because backups are good! Luckily, we have moved past this and there’s a simple service that schedules your EBS snapshots for you! This service is the CloudWatch Events service.

Sure, going 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 set up one of these bad boys!

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.

cloud watch events

 

Once you click on that, you are greeted with more information about the volume. The information you want is boxed in red:

cloud watch events

Ok, great! Now, let’s schedule those snapshots! Head back to the CloudWatch console, choose “Events” on the side, and click Create rule.

cloud watch events

Once you click on that, you will see the Create rule screen. I want to snapshot my EBS volume once a day, so I’m going to 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.

cloud watch events

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!

After you click Configure details, you move on to 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. After doing completing this step, you will be brought back to the “Configure rule details” screen.

Once everything is configured, go ahead and click Create rule!

cloud watch events

If there was no error, you will see the following screen:

cloud watch events

Congratulations! You are now snapshotting your EBS volume once a day! You can now, hopefully, focus your sleepless nights on development rather than worrying about your data volume disappearing into thin air! Go forth and conquer!

If you want to learn more about backing up your data through valuable hands-on experience with these concepts and many others, join our vibrant and growing community of some of the world’s leading cloud experts.


Linux Academy is launching 200+ new high-quality Courses, Learning Activities, and Challenges in November! Check out what’s coming with The Great 200+! 

November Course Launch

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get actionable training and tech advice

We'll email you our latest articles up to once per week.