Creating Daily EBS Snapshots

Creating actions to create and delete EBS snapshots

Matt Houser avatar
Written by Matt Houser
Updated over a week ago

Skeddly can create daily EBS snapshots for you automatically. In addition, it can delete old snapshots after a pre-determined number of days.

Here, we are going to use a single "Backup Multiple EBS Instances" action to create EBS snapshots at 2 AM. Each morning, Skeddly will look for EC2 instances in your selected region that has a resource tag named "skeddly:backup-schedule" and value "0200".

Once configured, you can add EC2 instances to your schedule by simply adding the resource tag to your EC2 instance. This can be accomplished using CloudFormation or other DevOps tools.

Prerequisites

  • A Skeddly account

  • An AWS credential (IAM role or IAM access key) registered with Skeddly

Setting Up Skeddly

Creating the Backup Action

  1. Go to the Actions list by clicking "Actions" then "Actions".

2. Click the "Create New Action" button.
3. In the action list, find and click on "Backup Multiple EC2 Instances".
4. In the "Name" field, give your action a friendly name. This is for your reference.
5. In the "Time of Day" field, put 2:00 AM. This will be the time that the EBS snapshots will be created.
6. In the "Time Zone" field, choose your local time zone. The EBS snapshots will be created at 2:00 AM in the selected time zone.
7. Set the "Repeat Type" field to be "Daily".
8. In the "Days of the Week" field, choose Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday.

So far, we have defined our schedule so that it will execute daily at 2:00 AM.

9. In the "Credentials and Region" section, select the AWS credentials and AWS region in which your EC2 instances live.

Now we are going to define how Skeddly will select the EC2 instances to backup.

10. In the "Instance Identification Method" field, choose "By EC2 Tag". This tells the action to find EC2 instances by matching resource tags.
11. In the "EC2 Tag Name", put "skeddly:backup-schedule". This is the name of the resource tag that will be used to find EC2 instances to backup.
12. In the "EC2 Tag Value", put "Equals" and "0200". This is the value of the resource tag that must match.
13. We recommend that your stop your EC2 instances when the EBS snapshots are created. This is not required though. To stop your EC2 instances, set "Consistency Method" to be "Stop Instance".
14. For easy identification later, we want to add some resource tags to the snapshots that are created. In the "EC2 Tags" field, add a tag named "skeddly:retention" and value of "7".

Creating the Delete Action

In this example, we will delete snapshots are are older than 7 days. The delete will happen only once per week, on Saturdays.

  1. Go to the Actions list by clicking "Actions" then "Actions".

2. Click the "Create New Action" button.
3. In the action list, find and click on "Delete EBS Snapshots".
4. In the "Name" field, give your action a friendly name. This is for your reference.
5. In the "Time of Day" field, put 11:00 PM. This will be the time that the EBS snapshots will be deleted.
6. In the "Time Zone" field, choose your local time zone. The EBS snapshots will be deleted at 11:00 PM in the selected time zone.
7. Set the "Repeat Type" field to be "Daily".
8. In the "Days of the Week" field, choose only Saturday.

So far, we have defined our schedule so that it will execute Saturdays at 11:00 PM.

9. In the "Credentials and Region" section, select the AWS credentials and AWS region in which your EBS snapshots are being created.

Now we are going to define how Skeddly will select the EBS snapshots to delete.

10. In the "Snapshot Identification Method" field, choose "By Resource Tag". This tells the action to find EBS snapshots by matching resource tags.
11. In the "Resource Tag Name", put "skeddly:retention". This is the name of the resource tag that will be used to find EBS snapshots to delete.
12. In the "Comparison", put "Equals" and "7". This is the value of the resource tag that must match.
13. For the "Delete Scheme" field, select "Simple, Oldest First".
14. For the "Older Than" field, put "7". This means only snapshots older than 7 days will be deleted.
15. By default, "Test Mode" is enabled. When enabled, the actions will execute on schedule, but snapshots will not be deleted. This lets you examine the logs to ensure the correct EBS snapshots are being deleted. Once you are happy with how the action is executing, modify your action configuration to disable "Test Mode".

The actions are complete.

However, by default, Skeddly won't have permissions to execute this action yet. So we need to use Skeddly's IAM Policy Generator to generate a new policy. Instructions for that can be found here: http://help.skeddly.com/credentials/amazon-web-services/iam-policy-generator

Adding EC2 Instances to Your Schedule

Each morning, Skeddly will execute our action and it will look for EC2 instances to backup. To add EC2 instances to this schedule, do the following in the AWS Management Console:

1. Go to the EC2 Management Console.
2. Go to the Instances list by clicking "Instances" on the left navigation pane.
3. Select the EC2 instance you want to add to the schedule.
4. In the details panel, click the "Tags" tab. This should show the list of existing resource tags.
5. Click the button titled "Add/Edit Tags".
6. Click the "Create Tag" button. A blank tag row should appear in the grid.
7. In the "Key" column, put "skeddly:backup-schedule".
8. In the "Value" column, put "0200".
9. Click the "Save" button.

Remember, tag comparison is case-sensitive.

Did this answer your question?