Amazon has announced a new service that will help customers manage their EBS volume snapshots in a very simple manner. The Data Lifecycle Manager service lets you setup a schedule to snapshot any of your EBS volumes during a specified time window.
In the past, AWS customers might need to come up with their own solution for snapshots or backups. Some apps moving to the cloud might not even need backups based on their deployment method and architectures. For everything else, we assume we’ll need to at least snapshot the EBS volumes that the EC2 instances are running on. Prior to the Data Lifecycle Manager, this could be accomplished through some fairly simple Lambda functions to snapshot volumes on a schedule. Now with the new service, there is a solution right in the EC2 console.
Using the Data Lifecycle Manager
To begin using the new service, open the EC2 console in your AWS account. If this is the first time using it, you’ll click the “Create Snapshot Lifecycle Policy” button to get started.
We’ll create a new policy which defines what volumes should be snapshotted and when to take these snapshots. First, give the policy a description so you’ll be able to recognize it later. The next piece is to identify which volume should be snapshotted. This is done using a tag on the volume (not the EC2 instance its connected to). I’ve used a method that snapshots EBS volumes with a tag key of “snap” and a tag value of “true”.
Next, we’ll need to define the schedule in which the volumes will be snapshotted. Give that schedule a name and then specify how often the snapshots will be taken. In this example, I’m taking a snapshot every 12 hours. The first snapshots need to know when to be initiated. Be sure to note that this time is UTC time, so do your conversions before you start with this process. After this, you’ll need to specify how many of the snapshots to keep. Its a bad idea to start taking lots of snapshots and not deleting them ever, especially in the cloud where you can keep as many as you’d like if you can stomach the bill.
Note: The snapshot start time is a general start time. The snapshots will be taken sometime within the hour you specify, but don’t expect that it will be immediately at this time.
You’ll also have the option to tag your snapshots. It probably makes sense to tag them somehow so that you know which ones might have been taken manually, and which were automated through the Data Lifecycle Manager. I’ve tagged mine with a key name LifeCycleManager and a value of true.
Lastly, you’ll need a role created that has permissions to create and delete these snapshots. Luckily, there is a “Default role” option in the console that will create this for you. Otherwise you can specify the role yourself.
After you create the policy, you’ll see it listed in your console. Its also worth noting that you could have multiple policies affecting the same volumes. For instance if you wanted to take snapshots every 6 hours, maybe you create a pair of policies since the highest frequency of snapshots that is available, is currently twelve hours.
If you wait for a bit, your snapshots should be taken you’ll notice that any of your EBS volumes that were properly tagged will be snapshotted. You can also see in the screenshot below, that the snapshot has the tag that I specified along with a few others that identify which policy created the snapshot.
The Data Lifecycle Manager service from AWS might not seem like a big deal, but its a lot nicer than having to write your own Lambda functions to snapshot and delete the snapshots on a schedule. Don’t worry though, you might still get some use out of your old Lambda code if you want to customize your snapshot methods or do something like create an AMI. If you’re just looking for the basics, try out the Data Lifecycle Manager. Right now you can test this out yourself in the N. Virginia, Oregon, and Ireleand regions through the AWS console or through the CLI. I expect this will be available in other regions and through CloudFormation shortly as well.