Elastic Cloud Gate

AWS Blog

How to Schedule Backup of EC2 AMI and delete old images

To schedule backup of the EC2 Instance (AMI):

  1. To open AMI wizard: go to EC2 and from the Menu select “AMI Backup/Copy”

    AMI Backup, Schedule and Maintenance
  2. In the upper section of the wizard setup, chose how frequently you want to create an AMI backup
    Occurrence:

    • Hourly – The image will be taken every given number of hours. In addition you can specify start and end time. For instance, if you want to take an image every 2 hours between 8AM and 7PM, the setup would look like this:

      AMI Backup, Schedule and Maintenance

      If you skip the start and end time, the image will be taken every given number of hours around the clock.
    • Daily – The image will be taken every selected day and time. For instance, to take an image every Monday, Wednesday and Friday at 9PM, the setup would look like this:

      AMI Backup, Schedule and Maintenance
    • Monthly – The image will be taken every given day of the month at given time. For example, to take an image every 3rd day of the month at 8AM, the setup would look like this:

      AMI Backup, Schedule and Maintenance

    You can setup multiple schedulers for the same EC2 instance and mix different frequencies if needed. For instance, to take an image every hour from 9AM to 5PM and another one daily at 11PM.

    AMI Backup, Schedule and Maintenance

  3. In the next section you can change the following settings:
    • Description – the description of the snapshot.
    • “Copy AMI to Different Region” this option when checked and AMI backup completed, will copy the new AMI to selected AWS region. You can select multiple destination regions. AMI will be copied to all AWS regions simultaneously.

    AMI Backup, Schedule and Maintenance

To schedule Maintenance (removal) of the old AMI:

  1. There are two options allowing to define which AMI should not be deleted:
    • a. “Keep All From Last” – this option will keep all AMIs created within the last x periods (period can be selected as hours, days, weeks, months or years). For example, if you want to keep all AMIs created within the last 7 days, you setup would look like this:

      AMI Backup, Schedule and Maintenance
    • b. “Keep One Per Period From Last” – this option will only keep the AMI created last in the given period (i.e. hours, days, weeks, months or years). For instance, if you want to keep one AMI per week from the last 4 weeks, the setup would look like this:

      AMI Backup, Schedule and Maintenance

    All AMIs which do not match scheduler will be deleted.

  2. When the AMI is created, for each volume that belongs to AMI there is a snapshot created as well. To remove snapshots along with the parent AMI, check option “Delete AMI Snapshots”.

    AMI Backup, Schedule and Maintenance
  3. You can setup advanced maintenance plan for AMI by creating multiple schedules. For example, to setup maintenance that would keep all AMIs from the last 7 days, 1 AMI per week from the last 4 weeks and 1 AMI per month from the last 4 months, the setup would look like this:

    AMI Backup, Schedule and Maintenance

, , , ,

Leave a Reply