Home AWSHow to Back Up EC2 Instances with EBS Snapshots and AMIs

How to Back Up EC2 Instances with EBS Snapshots and AMIs

by Knowledge Base Linux
How to Back Up EC2 Instances — How to Back Up EC2 Instances with EBS Snapshots and AMIs

If you run workloads on Amazon EC2, a solid ebs snapshots backup strategy is the simplest insurance against disk failure, accidental deletion, bad updates, and ransomware. Many teams launch an instance, configure it carefully, and then never create a recoverable copy. When something breaks, they discover that a running instance is not a backup at all. This guide explains how EBS snapshots and Amazon Machine Images (AMIs) work, how to create them manually in the console and with the AWS CLI, how to automate retention with Amazon Data Lifecycle Manager, and how to restore a volume when you actually need it. If you have not created an instance yet, start with our guide on how to launch your first EC2 instance on AWS, then return here to protect it. This article covers How to Back Up EC2 Instances in detail.

Understanding EBS Snapshots Backup Concepts – How to Back Up EC2 Instances

An Amazon EBS snapshot is a point-in-time, incremental backup of an EBS volume. The first snapshot copies all data on the volume. Later snapshots copy only the blocks that changed since the previous snapshot, which keeps storage costs and backup time low. Snapshots are stored in Amazon S3 behind the scenes, across multiple Availability Zones, but you manage them entirely through EC2. You can copy snapshots to another Region for disaster recovery, share them with another AWS account, encrypt them, and use them to create new volumes in any Availability Zone in the same Region.

An AMI is different. An Amazon Machine Image contains the information needed to launch a new instance: one or more EBS snapshots for the root and data volumes, plus metadata such as the architecture, virtualization type, and launch permissions. Think of a snapshot as a backup of a disk, and an AMI as a backup of a whole machine. Use snapshots when you need to protect or restore a single volume. Use an AMI when you want to clone a complete server, roll back an entire system after a failed upgrade, or create identical instances for scaling and testing.

Prerequisites for EBS Snapshots Backup – How to Back Up EC2 Instances

Before you start, make sure you have the following in place:

  • An AWS account with permission to use EC2, create snapshots, register AMIs, and manage lifecycle policies.
  • A running or stopped EC2 instance with at least one EBS volume attached.
  • The volume ID and instance ID, visible in the EC2 console under Instances and Storage.
  • For the CLI steps, the AWS CLI installed and configured with credentials that can call EC2 APIs.
  • A naming and tagging convention, for example Name, Project, and Retention tags, so old backups are easy to find and delete.

For the most consistent backup, stop the instance or pause application writes before taking a snapshot, especially for databases. EBS snapshots are crash-consistent by default, which is enough for many workloads, but application-consistent backups are safer for transactional systems. Also check our AWS category for more guides in this series.

Step 1: Create a Manual EBS Snapshot in the Console

Creating a snapshot manually is the fastest way to understand the process:

  1. Sign in to the AWS Management Console and open the EC2 dashboard.
  2. In the left navigation, choose Volumes under Elastic Block Store.
  3. Select the volume you want to protect, then choose Actions and Create snapshot.
  4. Enter a clear description, such as the instance name, date, and reason for the backup.
  5. Add tags such as Name, Project, and CreatedBy so the snapshot is easy to identify later.
  6. Choose Create snapshot, then open Snapshots in the left navigation to watch the status change from pending to completed.

A snapshot of a large volume can take time to complete, but you can keep using the volume while it is being created. The point in time is fixed when the snapshot starts. Remember that deleting a snapshot only removes the data blocks unique to that snapshot, so incremental chains stay efficient.

ebs snapshots backup automation with Data Lifecycle Manager

Step 2: Create an EBS Snapshot with the AWS CLI

The command line is better for repeatable work and scripting. First, list your volumes to confirm the volume ID:

aws ec2 describe-volumes --query "Volumes[*].[VolumeId,Size,State]" --output table

Then create the snapshot with a description and useful tags:

aws ec2 create-snapshot --volume-id vol-0123456789abcdef0 --description "Manual backup before upgrade" --tag-specifications 'ResourceType=snapshot,Tags=[{Key=Name,Value=web-server-backup},{Key=Project,Value=production}]'

The command returns a SnapshotId. Track its progress until the state is completed:

aws ec2 describe-snapshots --snapshot-ids snap-0123456789abcdef0 --query "Snapshots[*].[SnapshotId,State,Progress]" --output table

List all snapshots you own when auditing your backups:

aws ec2 describe-snapshots --owner-ids self --output table

Step 3: Create an AMI from Your Instance

To capture a complete machine image, use an AMI instead of a single-volume snapshot. In the console, select the instance, choose Actions, then Image and templates, then Create image. Give the image a name and description, decide whether the instance should reboot during imaging, and confirm which volumes are included. For a cleaner image, stop the instance first when possible.

From the CLI, the equivalent command is:

aws ec2 create-image --instance-id i-0123456789abcdef0 --name "web-server-2026-10-20" --description "Golden image before release" --no-reboot

Creating an AMI automatically creates snapshots of the attached volumes and registers them together. When you later deregister an AMI, remember to delete its associated snapshots separately, otherwise they continue to incur storage charges. A common pattern is to create an AMI before major changes, test the change, and keep the AMI for a defined retention period such as 7, 30, or 90 days.

Step 4: Automate Backups with Amazon Data Lifecycle Manager

Manual backups are forgotten. Amazon Data Lifecycle Manager, often called DLM, automates snapshot and AMI creation and deletion based on a policy. A good ebs snapshots backup routine should be policy-driven, not memory-driven.

  1. Open the EC2 console and choose Lifecycle Manager under Elastic Block Store.
  2. Choose Create lifecycle policy and select EBS snapshot policy or AMI policy.
  3. Choose the target resource type and select resources by tag, for example Backup=true.
  4. Set a schedule, such as daily creation at 02:00 UTC.
  5. Set retention, either by count, such as keep the last 7 snapshots, or by age, such as delete after 30 days.
  6. Optionally enable cross-Region copy for disaster recovery and fast snapshot restore where needed.
  7. Name the policy, review it, and create it. Tag your volumes or instances to match the policy target tags, otherwise nothing will be backed up.

Test the policy by checking that new snapshots appear after the first scheduled run and that their tags and descriptions are correct. Automation without verification is only a hope, so review the snapshot list weekly at first.

Step 5: Restore a Volume from a Snapshot

A backup is only proven when a restore works. To restore data from a snapshot:

  1. Open Snapshots in the EC2 console and select the snapshot to restore.
  2. Choose Actions and Create volume from snapshot.
  3. Choose the Availability Zone, volume type, and size. The new volume can be larger than the original, but not smaller.
  4. Create the volume and wait until its state is available.
  5. Attach it to an instance as an additional device, or stop the instance and replace its root volume if you are recovering a system disk.
  6. On Linux, mount the volume, verify the files, and expand the filesystem if you increased the size.

From the CLI, creating a restored volume looks like this:

aws ec2 create-volume --snapshot-id snap-0123456789abcdef0 --availability-zone ap-southeast-1a --volume-type gp3

After attaching, check the device and mount it:

lsblk
sudo mkdir -p /mnt/restore
sudo mount /dev/nvme1n1p1 /mnt/restore
ls -l /mnt/restore

Device names vary by instance family, so always confirm with lsblk before mounting. Never overwrite the only copy of your data during a restore test.

Cost, Retention, and Cleanup Notes

Snapshots are incremental, but they are not free. You pay for the data blocks stored, and old AMIs quietly leave orphaned snapshots behind when they are deregistered incorrectly. Control costs with three habits. First, set retention in every DLM policy; unlimited retention is unlimited cost. Second, review snapshots monthly and delete those with no matching AMI, instance, or business reason. Third, tag everything, because untagged snapshots are the ones nobody dares to delete and everybody keeps paying for.

Also consider the difference between backup and disaster recovery. A snapshot in one Region protects against volume and instance problems, but not against a Regional outage or an account compromise. For critical systems, copy snapshots to a second Region, consider AWS Backup for centralized policies across services, and protect important snapshots with Recycle Bin rules or snapshot locks so they cannot be deleted accidentally or maliciously.

Troubleshooting Common Snapshot Problems

Snapshot stuck in pending: Large or busy volumes take longer. Check progress with describe-snapshots and avoid starting many snapshots of the same volume at once. Permission denied: Your IAM user or role needs ec2:CreateSnapshot, ec2:CreateImage, and DLM permissions; check the exact denied action in the error message. Policy creates nothing: The target tags do not match your resources, or the policy is not in the enabled state. Restored volume will not mount: You may be mounting the whole disk instead of a partition, or the filesystem needs a check; verify with lsblk and file -s. AMI creation fails: The instance may have instance-store volumes or marketplace restrictions; review the included volumes and product codes.

For official details on how snapshots work, see the Amazon documentation on Amazon EBS snapshots.

Conclusion

A reliable ebs snapshots backup process combines three layers: manual snapshots for immediate protection before risky changes, AMIs for complete machine recovery and cloning, and Data Lifecycle Manager policies for hands-off daily protection with sensible retention. Create your first snapshot today, automate it with DLM, and perform one test restore. That single restore test turns a theoretical backup into a recovery plan you can trust when production is on the line.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.