grandeduc - Fotolia


How to automate AWS EBS snapshot recovery

Automating Elastic Block Store snapshot recovery frees up admins' time, allowing them to focus on other value-add tasks like development.

Managing the cloud often involves a lot of moving parts. Tuning an AWS cloud setup so services run without human...

intervention can alleviate some management work and allow admins to focus on system reliability, availability and development.

After saving an Elastic Block Storage (EBS) to Simple Storage Service (S3), admins can simplify the process further through automation. If you ever need to restore an Amazon Web Services (AWS) EBS snapshot, recovery is just a few clicks away.

AWS has many pre-built tools to help with automation. CloudWatch triggers, for example, can automatically recover Elastic Compute Cloud (EC2) instances and Elastic Beanstalk, which can seamlessly perform autoscaling and load balancing of a cloud application. To enable a CloudWatch trigger to recover certain EC2 instances that experience a hardware failure, create a CloudWatch alarm for the metric StatusCheckFailed_System and choose "Recover this instance" and then select "EC2 Action." If a system failure event occurs, this trigger will reboot the failed instance under the exact same configuration -- Elastic IP address, EBS volume attachments, and other configuration settings.

Another way to automatically save AWS EBS snapshots is through command-line interface (CLI) scripting. To automatically save EBS snapshots, use the cron utility on a Linux EC2. For Windows instances, use the AT command or schtasks utility in a similar way.

Run the AWS EC2 "Create snapshot" CLI to create the snapshot on S3. Categorize your new snapshot using the AWS EC2 "Create tag" CLI to attach specific metadata to help quickly identify the desired snapshot if recovery is needed. Here is an example of what the command will look like:

ec2-create-snapshot vol-1234abcd --description "website data"
ec2-create-tags --resource snapshot-id --tags Key="version", Value="1.0"

AWS CLI commands cannot execute in your EC2 unless they are specifically given permission to do so. To configure EC2 to run these commands you can use either AWS keys or an AWS identity access management role. Embedding EC2 instances with role-based security offers a higher level of security than using plain-text AWS key security credentials.

Restoring a snapshot in AWS

Depending on whether the snapshot is a root volume or a data-based volume, there are a few ways to bring a snapshot back to life -- the AWS Management Console or the CLI SDK. From the AWS console, identify the snapshot you want to recover by searching for a tag or other snapshot attributes, such as the snapshot name or volume ID. Once you've identified the target snapshot, right-click over the snapshot name and select "Create Volume." Once the volume has been created from the snapshot it can be attached to an existing instance. You can also create a new instance with this new volume as the root volume.

About the author:
Russ Vanderpool, who holds MSCS and MBA degrees, is a technologist interested in using cloud technology to deliver solutions, help companies better serve customers and identify new businesses. He has hands-on experience as an architect and developer and a business adviser across the finance, energy, education, technology and nonprofit sectors. Russ has architected and built a cloud infrastructure for a green tech company, and while working for Japan's largest systems integration firm, he developed proprietary object-oriented database visualization software for that market.

Next Steps

Manage snapshots in AWS with Asigra tool

Using AWS S3 for data archiving

Data storage alternatives to AWS EBS

Dig Deeper on Amazon S3 (Simple Storage Service) and backup