In one of the previous blog, we looked about attaching an EBS Volume to a Linux EC2 instance. You can think of EBS Volume has a hard disk, multiple of which can be attached to the Linux EC2 instances for storing the data.
The Snapshots can be created manually using the CLI and API, but it would be good to automate the creation of the Snapshots. There are multiple approaches for the same, which we will look into it.
Approach 1 : This is the easiest approach of all without any coding as mentioned here. This uses CloudWatch events and is not really flexible, it just gives the option to take Snapshots at regular intervals using Cron expression. Other that that it doesn't give much flexibility. Lets say we want to take Snapshots of EC2 instances which have been tagged for backup out of all the EC2 instances then this approach would not be good enough.
Approach 2 : This approach is a bit more flexible, but we need to code and need to be familiar with the AWS Lambda service. Java, Python, C# and Node.js can be uses as of now against the Lambda service. These articles (1, 2) give details on creating a Lambda function using Python and trigger it at regular intervals to create a Snapshot out of the Volume. The articles are a bit old, but the procedure is more of less the same. The articles mention about scheduling in the Lambda Management Console, but the scheduling has to be done from the CloudWatch Events as mentioned here.
The EBS Volumes where the data is stored can be corrupted or there can be some sort of failure. So, it's better to take a Snapshot (backup) from the Volume at regular intervals depending upon the requirement. In case of any failures, the Volume can be created from the Snapshot as shown below. Here is the AWS documentation on how to create an Snapshot and here is the documentation for restoring the corrupted/failed Volume from a healthy Snapshot. Here is a good documentation on what Snapshot is all about.
Approach 1 : This is the easiest approach of all without any coding as mentioned here. This uses CloudWatch events and is not really flexible, it just gives the option to take Snapshots at regular intervals using Cron expression. Other that that it doesn't give much flexibility. Lets say we want to take Snapshots of EC2 instances which have been tagged for backup out of all the EC2 instances then this approach would not be good enough.
Approach 2 : This approach is a bit more flexible, but we need to code and need to be familiar with the AWS Lambda service. Java, Python, C# and Node.js can be uses as of now against the Lambda service. These articles (1, 2) give details on creating a Lambda function using Python and trigger it at regular intervals to create a Snapshot out of the Volume. The articles are a bit old, but the procedure is more of less the same. The articles mention about scheduling in the Lambda Management Console, but the scheduling has to be done from the CloudWatch Events as mentioned here.
No comments:
Post a Comment