Skip to main content

Cloud

AWS – EBS Snapshot Scheduler

AWS – EBS Snapshot Scheduler 

It is a best practice to regularly backup the Amazon EC2 instances using AWS Elastic Block Storage (EBS) snapshot. EBS Snapshots are incremental, which means that only the blocks on the device that have been changed since the last snapshot are saved. EBS Snapshots are backed up by Amazon S3 for High-availability. Snapshots are constrained to the region in which they were created and are used to create the new volumes.

Amazon has provided the solution for Incremental snapshots with a wide range of features which allow us to automatically take the snapshots of the EBS volumes.  The solution requires us to download the template, using this url, and create the new stack.

Snapshot Scheduler Architecture:

Snapshot Scheduler Architecture

 The cloudformation stack (ebs-snapshot-scheduler.template) is going to create the following resources

  • Two DynamoDb Tables
    • Scheduler-EBS-Snapshot-Policy: Table with the configuration details including “EC2 Key Tag Name”, “Default time to schedule backup”, “Time zone” etc.
    • Scheduler-EBS-Snapshot-History: History details of each snapshot taken using this solution will be recorded into this table.
  • Two Lambda Services
    • EBS-Snapshot-Scheduler-SolutionHelper :This function is invoked only once(at the time of creation) to record the default values to the DynamoDb Policy table.
    • EBS-Snapshot-Scheduler-ebsSnapShotLambda: This Service is going to use the AWS EC2 API to look through all the EC2 instances to perform automatic sansphots.
  • Cloudwatch Event :
    • EBS-Snapshot-Scheduler-ScheduledRule : CloudWatch Event rule is created to invoke the Lambda service for every 5 Minutes to check for any EBS Volume snapshots to be taken within the current period.

Once the CloudFormation stack has been created, we need to configure the EC2 instances to schedule the backups. EC2 instances should have the Tag “scheduler:ebs-snapshot” created under the “EC2-Tags” with the value indicating whether the Snapshot has to be taken.  The EC2 instance tag “scheduler:ebs-snapshot” can have the following values:

  • “True” : Snapshots will be scheduled to be taken at the default time given while creating the CloudFormation.
  • “0800,6;utc;all” : Snapshots will be scheduled at 8.00 AM UTC all the weekdays with the retention period of 6 days.

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.

Sridhar Anchoori

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram