EC2 Automated snapshots Backup

How to take automated backups in Ec2 Volumes.

EC2 Automated snapshots Backup

August 3, 2018 / Eternal Team

Mechanism

Amazon has not yet presented managed automated backups in EC2 service. It is only available in RDS service. But using CloudWatch Events we can configure automated snapshots for our EC2 volumes using Lamda functions or by calling EC2 CreateSnapshot API on the behalf of us.

AWS CloudWatch is monitoring service and we will use its sub service – Events.

We will configure rules in CloudWatch Events to take snapshots by calling EC2 CreateSnaphot API with IAM role.

Events will take Snapshot for desired volume id and then the Snapshot will be stored into S3.

After the Snapshot process ends Events will trigger SNS topic to send notification about operation to SNS topic subscribers.

Cloudwatch

Amazon CloudWatch is a monitoring service for AWS cloud resources and the applications running on it. CloudWatch helps you to collect and track metrics for your AWS resources.

You can configure alarm to help you react when changes happen to your resources. For example, you can create a alarm when your EC2 instance is utilizing more CPU than the normal usage limit.

You can do more than creating alarm by leveraging the CloudWatch Events feature. In this tutorial, we are going to see the one such use case of CloudWatch Events where you can automate the EBS (Elastic Block Storage) snapshots creation.

Create a SNS Topic

A topic is a communication channel to send messages and subscribe to notifications. It provides an access point for publishers and subscribers to communicate with each other. In this section you create a topic named MyTopic.

To create a topic

In the Amazon SNS console, click Create topic.

The Create topic dialog box appears.

In the Topic name box, type a topic name.

Click Create topic.

The new topic appears in the Topics page.

Select the new topic and then click the topic ARN.

Copy the topic ARN for the next task.

Topic Subscription

To receive messages published to a topic, you have to subscribe an endpoint to that topic. An endpoint is a mobile app, web server, email address, or an Amazon SQS queue that can receive notification messages from Amazon SNS. Once you subscribe an endpoint to a topic and the subscription is confirmed, the endpoint will receive all messages published to that topic.

To subscribe to a topic

Open the Amazon SNS console at https://console.aws.amazon.com/sns/v2/home.

Click Create subscription.

The Create Subscription dialog box appears.

In the Topic ARN field, paste the topic ARN you created in the previous task, for example:arn:aws:sns:us-west-2:111122223333:MyTopic.

In the Protocol drop-down box, select Email.

In the Endpoint box, type an email address you can use to receive the notification.

Click Create subscription.

Go to your email application and open the message from AWS Notifications, and then click the link to confirm your subscription.

Your web browser displays a confirmation response from Amazon SNS.

Now you have created a SNS topic and confirmed email address of end point. You will need this SNS topic to get alerts on automated backup status. In next steps you will learn how to take automated backups for EC2 volumes.

Schedule Automated Snapshots EC2

Open the Cloudwatch console at https://eu-central-1.console.aws.amazon.com/cloudwatch.