Backups in AWS (EBS snapshots and AMIs)
Topic: Cloud aws core
Summary
Back up EBS volumes with snapshots (incremental, stored in S3 by AWS). Create snapshots manually or with Data Lifecycle Manager (DLM). AMIs include root volume snapshots. Use this when implementing backup strategy for EC2 or when automating snapshot creation and retention.
Intent: How-to
Quick answer
- EBS snapshot: EC2 -> Volumes -> select volume -> Create snapshot. Snapshot is incremental (only changed blocks); create from consistent state (stop instance or use application-consistent method). Restore: Create volume from snapshot; attach to instance.
- Automate: use AWS Data Lifecycle Manager (DLM) to create snapshots on schedule and delete after retention. Tag volumes so DLM targets the right ones. Or use Lambda and EventBridge for custom schedule.
- AMI: creating an AMI from an instance creates snapshots of attached EBS volumes. Use for golden image or disaster recovery; copy AMI to another region for DR. Test restore from snapshot and from AMI.
Prerequisites
Steps
-
Create EBS snapshot
EC2 -> Volumes -> select volume -> Actions -> Create snapshot. Add tag for identification. For consistency: stop instance or use fsfreeze and script; then create snapshot. Snapshot is async; check status in console.
-
Restore from snapshot
EC2 -> Snapshots -> select snapshot -> Actions -> Create volume. Choose AZ (same as instance or same region). Attach volume to instance; mount and verify. For root: create AMI from snapshot or replace root volume (stop, detach, attach new, start).
-
Automate with DLM
EC2 -> Lifecycle Manager -> Create lifecycle policy. Target volumes by tag; schedule (e.g. daily 2 AM); retention (e.g. 7 days). DLM creates and deletes snapshots. Tag volumes consistently.
-
AMI for full instance backup
Create Image from instance (includes root volume snapshot). Use for DR or golden image. Copy AMI to another region if needed. Deregister old AMI and delete snapshots when superseded.
Summary
Create EBS snapshots for volume backup; restore by creating a volume from a snapshot. Automate with DLM or Lambda. Use AMIs for full instance backup. Use this to implement and test EC2 backup and restore.
Prerequisites
Steps
Step 1: Create EBS snapshot
Create a snapshot from the volume; use a consistent state (stop or app-consistent) when required.
Step 2: Restore from snapshot
Create a volume from the snapshot; attach and mount; verify data.
Step 3: Automate with DLM
Use DLM to create and retain snapshots on a schedule; tag volumes for targeting.
Step 4: AMI for full instance backup
Create an AMI from the instance for full backup or golden image; copy to another region for DR.
Verification
- Snapshots are created and retained; a test restore from snapshot and from AMI succeeds.
Troubleshooting
Snapshot pending long — Large volume or first snapshot; wait or check service health. Restore volume wrong AZ — Create volume in the same AZ as the instance (or migrate instance).