Last update: 2019-08-19

Backing up your cloud instances with AWS Lifecycle Policy

Are you doing backups of your cloud instances? The cloud is great because a lot of the regular maintenance is delegated to the cloud provider. If you want to run a new VM in the AWS cloud, you go to the console and spin up a new EC2 instance. You don't have to worry about provisioning the hardware, worry about power management, cooling, or even having enough resources on your hypervizor to get that new VM powered up. All of that is taken care of automatically by the Amazon staff.

However, the cloud takes care of very specific tasks, and backups isn't one of them. Even for a service like S3, where Amazon claims a 99.5% to 99.99% reliability, it's still up to you to make sure your data is backed up. Deciding what you should be backing up is totally dependent on your specific workloads, but anything that contains user data or other types of data that would be costly or time sensitive to replace, should probably be backed up.

When it comes to EC2 instances, snapshots is the easiest type of backup to have. Snapshots are easy to deal with, easy to create and easy to restore. And for automated snapshots, Amazon provides the Lifecycle Manager. This allows you to define a schedule and retention period for when your EC2 instances should be backed up. It takes just a few minutes to setup, and there's no reason why you shouldn't be using it if you have cloud instances with precious data in them.

To create a policy, go to the AWS console under the EC2 section, then click on the Lifecycle Manager on the left pane. There, you'll be able to create a new policy:

Each policy contains 3 important parts:

  • First, you need to define which instances will be backed up. This is typically used by defining tags. For example, you can decide that you only need EC2 instances with the tag Environment set to Production should be part of this policy.
  • Next, define when the snapshots should be taken. You can set it to Every 24 hours for example, to get a snapshot every day.
  • Finally, you should setup a retention time for those snapshots. For example, you can set 90 days so that backups older than 3 months will be automatically deleted.

The AWS Lifecycle Policy isn't the most customizable system out there, for example it doesn't allow you to have additional logic in there such as what a Lambda function could do, but for the majority of cases it's more than enough to handle your EC2 instance backup needs.

Looking to expand into the cloud? See what a certified freelancer can do for you.
