EC2 backup and recovery
By Cameron Chapman, Culture editor at Panama
October 12, 2021
EC2 Auto Recovery

Amazon EC2's auto-recovery feature is designed to boost instance availability. When faced with detected failures, such as hardware malfunctions on the host or issues requiring AWS intervention, EC2 will automatically recover the instance. This recovery can be instigated by the instance's default configurations or by setting up an Amazon CloudWatch alarm for system status check failures.
To disable simplified automatic recovery during instance launch:
  • Open the Amazon EC2 console.
  • In the navigation pane, choose Instances > Launch instance.
  • Under Advanced details, locate Instance auto-recovery and select Disabled.
  • Configure the remaining instance launch settings as desired and then launch the instance.


To disable simplified automatic recovery for a running or stopped instance:
  • Open the Amazon EC2 console.
  • Navigate to Instances in the navigation pane.
  • Select the desired instance, then go to Actions > Instance settings > Change auto-recovery behavior.
  • Opt for Off and then click Save.

To set the automatic recovery behavior to default for a running or stopped instance:

  • Open the Amazon EC2 console.
  • In the navigation pane, opt for Instances.
  • Highlight the instance, then navigate to Actions > Instance settings > Change auto-recovery behavior.
  • Select Default (On), and then click Save.
Upon auto recovery:
  • The instance retains all essential attributes, including the instance ID, both private and public IP addresses, Elastic IP addresses, and all other associated metadata.
  • The recovery involves an instance reboot, during which any in-memory data is lost.
  • If the impaired instance belongs to a placement group, the recovered instance remains in that same group.
Issues that might necessitate instance recovery include:
  • Loss of network connectivity
  • Sudden loss of system power
  • Software malfunctions on the physical host
  • Hardware issues on the physical host that compromise network accessibility

EC2 Backup

Backing up your EC2 instances ensures data durability, mitigates risks associated with hardware failures, and facilitates data migration. AWS offers a variety of tools for this purpose, with Amazon EBS Snapshots and Amazon Machine Images (AMIs) being the most prominent.
1. EBS Snapshots

An EBS snapshot provides a point-in-time copy of your EBS volume, preserving both its data and structure. Snapshots play a crucial role in data recovery, enabling the restoration of volumes to their captured state. They can also assist in data migration across Availability Zones or even AWS regions.

Creating and Using EBS Snapshots:
  • To create a snapshot, navigate to the EBS section of the EC2 dashboard, select the desired volume, and choose the “Create Snapshot” option.
  • At the top right corner you will find "Create Snapshot" button.
  • Choose Volume to create a snapshot from a specific volume. Choose Instance to create snapshots from all of the volumes attached to an instance. Click on "Create snapshot" after choosing the Resource Type.
  • Snapshots can be initiated manually or automated with policies via Amazon Data Lifecycle Manager (DLM).
  • For data recovery or volume creation, you can instantiate a new EBS volume from a pre-existing snapshot.
2. Amazon Machine Images (AMIs):

While EBS Snapshots capture the state of a singular volume, AMIs are broader; they store the complete server configuration, encompassing the OS, attached EBS volumes, and software packages. AMIs are instrumental in EC2 scaling and replication, allowing for quick instance deployment with consistent configurations.

Templates and Images:

Image: An image (in the context of AMIs) is essentially a packaged-up server. It's a static, unalterable snapshot of an instance at a given point in time.
Template: In a broader IT context, a template often refers to a base configuration that can be reused multiple times. An AMI acts as a template for launching new EC2 instances. By using this 'template', you can create identical and consistent environments, be it for scaling, replication, or testing.



Creating and Using AMIs:

Step 1:
  • Log into AWS Management Console:
Navigate to the Amazon EC2 console
  • Access Your Instances:
In the navigation pane, click on "Instances" to view a list of your running EC2 instances.
  • Select the Desired EC2 Instance:
From the list, choose the instance you want to create an image of.
Step 2: Initiate the Image Creation Process:
With the instance selected, click on the "Actions" dropdown menu and hover over "Create Image" in the dropdown.
Step 3: Configure Image Details:
  • A dialog box will appear prompting you to enter details for the new image.
  • Provide a name and description for the AMI. This helps in identifying and managing your AMIs effectively.
  • You can also configure additional settings, such as whether to reboot the instance before creating the image. AWS recommends a reboot for a clean state, but it's not mandatory.

Create the Image:
  • After configuring your settings, click the “Create Image” button.
  • On the EC2 dashboard, after selecting a running instance, opt for the “Create Image” option to generate an AMI.
  • Once the AMI is available, you can use it to launch new EC2 instances. This is especially useful for maintaining consistency across instances or deploying pre-configured server environments.
  • Sharing AMIs across different AWS accounts or making them public is also feasible, though be cautious about security implications.
  • You can terminate the Amazon Machine Image (AMI) instance after utilization since the persistent existence of an AMI incurs billing charges.
Backup Considerations:
Regularity: Determine the frequency of your backups based on data volatility and business needs.
Retention: Define the lifespan of backups, considering factors like compliance, storage costs, and recovery scenarios.
Costs: Both EBS Snapshots and AMIs incur storage costs, so it's essential to monitor and optimize backup storage regularly.

By integrating EBS Snapshots and AMIs into your EC2 backup strategy, you can ensure data resilience, streamline disaster recovery, and maintain operational consistency across your AWS infrastructure.