EBS Snapshots
What is a Snapshot?
A snapshot is a point-in-time copy of an EBS volume. It is the primary backup mechanism for EBS.
┌─────────────────────────────────────────────────────────────┐
│ EBS SNAPSHOT │
├─────────────────────────────────────────────────────────────┤
│ │
│ EBS Volume Snapshot │
│ (100 GB) (in S3) │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ █████████████ │ ─────────► │ ░░░░░░░░░░░░░ │ │
│ │ █████████████ │ create- │ Data copy │ │
│ │ █████████████ │ snapshot │ (compressed) │ │
│ │ ░░░░░░░░░░░░░ │ │ │ │
│ └─────────────────┘ └─────────────────┘ │
│ Used: 60 GB Stored: ~60 GB │
│ Free space: 40 GB (actual data) │
│ │
│ Features: │
│ • Stored in S3 (managed by AWS) │
│ • Incremental after the first one │
│ • Can be copied between regions │
│ • Basis for creating volumes or AMI │
│ │
└─────────────────────────────────────────────────────────────┘
Incremental Snapshots
┌─────────────────────────────────────────────────────────────┐
│ INCREMENTAL SNAPSHOTS │
├─────────────────────────────────────────────────────────────┤
│ │
│ First snapshot: COMPLETE │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Volume: 100 GB │ │
│ │ Data: 60 GB │ │
│ │ │ │
│ │ Snapshot 1: 60 GB copied │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ Subsequent snapshots: INCREMENTAL │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ From Snapshot 1: │ │
│ │ • 5 GB of data changed │ │
│ │ • 2 GB of new data │ │
│ │ │ │
│ │ Snapshot 2: only 7 GB copied! │ │
│ │ (not 60 GB complete) │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ Advantages: │
│ ✅ Faster │
│ ✅ Less storage │
│ ✅ Less costly │
│ │
│ Deletion: If you delete Snapshot 1, │
│ Snapshot 2 remains functional (AWS manages dependencies) │
│ │
└─────────────────────────────────────────────────────────────┘
Create a Snapshot
Via Console
1. EC2 → Elastic Block Store → Volumes
2. Select the volume
3. Actions → Create snapshot
4. Description: "backup-before-update"
5. Add tags (recommended)
6. Create snapshot
Via CLI
# Create a snapshot
aws ec2 create-snapshot \
--volume-id vol-0123456789abcdef0 \
--description "Daily backup - 2024-12-18" \
--tag-specifications 'ResourceType=snapshot,Tags=[{Key=Name,Value=daily-backup},{Key=Environment,Value=prod}]'
# View snapshots
aws ec2 describe-snapshots \
--owner-ids self \
--query 'Snapshots[*].[SnapshotId,VolumeId,State,StartTime,Description]' \
--output table
Restore from a Snapshot
Create a New Volume
# Create a volume from a snapshot
aws ec2 create-volume \
--snapshot-id snap-0123456789abcdef0 \
--availability-zone us-east-1a \
--volume-type gp3 \
--tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=restored-volume}]'
Restore in Another AZ/Region
┌─────────────────────────────────────────────────────────────┐
│ CROSS-AZ / CROSS-REGION RESTORATION │
├─────────────────────────────────────────────────────────────┤
│ │
│ Volume us-east-1a ──► Snapshot ──► Volume us-east-1b │
│ │ │
│ │ (copy snapshot) │
│ ▼ │
│ Snapshot ──► Volume eu-west-1a │
│ (eu-west-1) │
│ │
│ # Copy a snapshot to another region │
│ aws ec2 copy-snapshot \ │
│ --source-region us-east-1 \ │
│ --source-snapshot-id snap-xxx \ │
│ --region eu-west-1 \ │
│ --description "DR copy" │
│ │
└─────────────────────────────────────────────────────────────┘
Backup Best Practices
Retention Strategy
┌─────────────────────────────────────────────────────────────┐
│ RETENTION STRATEGY │
├─────────────────────────────────────────────────────────────┤
│ │
│ Example: "Grandfather-Father-Son" Strategy │
│ │
│ Daily (Son): │
│ • Snapshot every night │
│ • Keep 7 days │
│ │
│ Weekly (Father): │
│ • Snapshot every Sunday │
│ • Keep 4 weeks │
│ │
│ Monthly (Grandfather): │
│ • Snapshot on the 1st of the month │
│ • Keep 12 months │
│ │
│ Result: │
│ • 7 + 4 + 12 = 23 snapshots maximum │
│ • One-year coverage │
│ • Controlled cost │
│ │
└─────────────────────────────────────────────────────────────┘
Automation with AWS Backup
┌─────────────────────────────────────────────────────────────┐
│ AWS BACKUP │
├─────────────────────────────────────────────────────────────┤
│ │
│ AWS service to automate backups │
│ │
│ Configuration: │
│ 1. Create a Backup Plan │
│ 2. Define rules (frequency, retention) │
│ 3. Assign resources (volumes, by tags) │
│ 4. AWS automatically creates snapshots │
│ │
│ Advantages: │
│ ✅ No scripts to maintain │
│ ✅ Centralized management │
│ ✅ Compliance and reporting │
│ ✅ Automatic cross-region │
│ │
│ Alternative: Data Lifecycle Manager (DLM) │
│ Simpler but fewer features │
│ │
└─────────────────────────────────────────────────────────────┘
Snapshot Costs
┌─────────────────────────────────────────────────────────────┐
│ SNAPSHOT COSTS │
├─────────────────────────────────────────────────────────────┤
│ │
│ Price: ~$0.05 per GB-month │
│ │
│ Example: │
│ • Volume 100 GB │
│ • 60 GB actual data │
│ • 7 snapshots (1 week daily) │
│ │
│ First snapshot: 60 GB │
│ Subsequent: ~5 GB each (incremental) │
│ Total stored: 60 + (6 × 5) = 90 GB │
│ │
│ Monthly cost: 90 × $0.05 = $4.50 │
│ │
│ ⚠️ Forgotten snapshots cost! │
│ Regularly audit and delete unnecessary ones │
│ │
└─────────────────────────────────────────────────────────────┘
Snapshot vs AMI
┌─────────────────────────────────────────────────────────────┐
│ SNAPSHOT vs AMI │
├─────────────────────────────────────────────────────────────┤
│ │
│ SNAPSHOT AMI │
│ ──────── ─── │
│ • Backup of ONE volume • Complete image │
│ • Data only • OS + Config + Data │
│ • For data restoration • For launching instances │
│ • Block level • Instance level │
│ │
│ Relation: │
│ AMI = Metadata + Snapshots of volumes │
│ │
│ ┌────────────────────────────────────────┐ │
│ │ AMI │ │
│ │ ┌──────────────────────────────────┐ │ │
│ │ │ Metadata (name, arch, etc.) │ │ │
│ │ └──────────────────────────────────┘ │ │
│ │ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ Snapshot │ │ Snapshot │ │ │
│ │ │ Root volume │ │ Data volume │ │ │
│ │ └──────────────┘ └──────────────┘ │ │
│ └────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Useful Commands
# List all snapshots
aws ec2 describe-snapshots --owner-ids self
# Delete a snapshot
aws ec2 delete-snapshot --snapshot-id snap-xxx
# Copy to another region
aws ec2 copy-snapshot \
--source-region us-east-1 \
--source-snapshot-id snap-xxx \
--region eu-west-1
# Share a snapshot with another account
aws ec2 modify-snapshot-attribute \
--snapshot-id snap-xxx \
--attribute createVolumePermission \
--operation-type add \
--user-ids 123456789012
# Find orphaned snapshots (without source volume)
aws ec2 describe-snapshots \
--owner-ids self \
--query 'Snapshots[?!VolumeId]'
Validation Quiz
- What is an incremental snapshot?
- Where are snapshots stored?
- Can you create a volume in a different AZ from a snapshot?
- What is the relationship between AMI and snapshot?
- How to automate snapshots?
Next section: Lab: EBS Storage