Why Use DLM? The Problem It Solves
Before DLM, managing EBS snapshot schedules and retention required building custom solutions, often involving AWS Lambda functions and Amazon CloudWatch Events. This approach was complex, error-prone, and required ongoing maintenance.
DLM provides a fully managed solution with key benefits:
-
Automation: Set up policies once and let AWS handle the creation, copying, and deletion of snapshots automatically.
-
Cost Savings: By enforcing retention rules, DLM automatically deletes old, unneeded snapshots, ensuring you don't pay for storage you no longer require.
-
Improved Compliance: Helps enforce your organization's backup and retention policies for compliance and auditing purposes.
-
Reduced Operational Overhead: Eliminates the need to write and maintain custom backup management scripts.
Core Components of a DLM Lifecycle Policy
A DLM policy is the core resource you create to define your automation rules. It consists of several key components:
1. Policy Type
You can create policies to manage:
-
EBS Snapshots: The most common use case, for backing up individual EBS volumes.
-
EBS-backed AMIs: For creating and managing the lifecycle of Amazon Machine Images created from your EC2 instances.
2. Target Resources (Using Tags)
DLM identifies which resources to back up by using resource tags. You do not specify individual volume or instance IDs.
-
How it works: You define a target tag in your policy (e.g.,
Key=backup
,Value=daily
). DLM will then find and back up all EBS volumes in that region that have this specific tag. -
Best Practice: This tag-based approach allows you to easily include new EBS volumes in your backup schedule simply by applying the correct tag to them.
3. Schedules and Retention Rules
This is the heart of the policy, where you define your backup timing and retention strategy. A single policy can have up to four schedules.
Each schedule defines:
-
A Frequency: How often the backup is created (e.g., every 12 or 24 hours, daily, weekly, monthly, or a custom cron expression).
-
A Start Time (UTC): The time of day the backup process will begin.
-
A Retention Rule: How long the backups from this schedule should be kept. This can be:
-
Count-based: Retain a specific number of the most recent snapshots (e.g., "keep the last 7 daily snapshots").
-
Age-based: Retain all snapshots for a specific period (e.g., "keep all weekly snapshots for 4 weeks" or "keep all monthly snapshots for 1 year").
-
DLM automatically deletes the oldest snapshots from that schedule once the retention count or age limit is exceeded.
Key Features
Cross-Region Copy for Disaster Recovery
Within a policy schedule, you can configure DLM to automatically copy completed snapshots to one or more different AWS Regions.
-
This provides a simple, automated way to create offsite backups for disaster recovery.
-
The copied snapshots in the destination region can have their own independent retention policy.
Fast Snapshot Restore (FSR)
You can enable Fast Snapshot Restore (FSR) for snapshots created by a specific schedule.
-
FSR pre-warms the snapshot, allowing you to create fully-initialized EBS volumes from it with maximum performance instantly, eliminating the high latency normally associated with accessing a new volume's blocks for the first time.
-
Note that FSR incurs additional costs.
Application-Consistent Snapshots (Pre/Post Scripts)
For applications that need to be quiesced for a consistent backup (like databases), DLM can orchestrate pre-script and post-script actions.
-
It uses AWS Systems Manager (SSM) to run a custom SSM document on the attached EC2 instance.
-
This allows you to run commands to flush application buffers and freeze I/O before the snapshot is taken, and then run commands to thaw the I/O after the snapshot is complete.
DLM vs. AWS Backup
It's important to know when to use DLM versus the broader AWS Backup service.
| Feature | Amazon DLM | AWS Backup |
| :--- | :--- | :--- |
| Scope | Manages only EBS snapshots and EBS-backed AMIs. | A centralized backup service for many AWS services (EBS, RDS, DynamoDB, EFS, S3, etc.). |
| Complexity| Simpler, more direct for its specific purpose. | More complex, but provides a single pane of glass for all backup activities. |
| Compliance | Provides automation for retention. | Offers advanced compliance features like Backup Vaults with Vault Lock (WORM). |
| When to Use| When your primary goal is to automate the creation, retention, and cleanup of EBS snapshots or AMIs. | When you need a comprehensive, organization-wide backup strategy that covers multiple different AWS services. |