Site icon UnixArena

Amazon EC2 – Disaster Recovery using DLM – Cross Region snapshot – EC2 AMI

Data is a critical asset for any business in the digital world. so backing up your data regularly is critical for any company with business continuity in mind. This is applicable whether the company is using an on-premises data center or a public cloud like AWS, Azure, or GCP. At the same time, you need to keep the cost in mind when you design for data protection using any third-party tool or cloud-native tools. This article will walk you through how to use Amazon Data Lifecycle Manager (DLM) to lower operational costs and reduce the complexity of managing the backup operations using EBS snapshots. EBS-backed AMIs are a convenient way to back up your block-level data. EBS snapshots are block-level, point-in-time, incremental copies of your Amazon EBS volumes for backup, or disaster recovery (DR) purposes.

The organization’s IT policy defines the snapshots to be taken on a specified schedule (hourly, daily, weekly, etc.) to meet business continuity and data protection requirements. This article will walk you through how can use DLM lifecycle policies to automate the creation, retention, and deletion of Amazon EBS snapshots. 

We will be trying to achieve the following using the Amazon DLM policy.

Amazon DLM – EBS snapshot backed AMI

Backup policies Options and resource tagging

Amazon Data lifecycle manager works based on resource tagging. Before creating the policy, you need to define the recovery point objectives (RPO) and recovery time objectives (RTO)  for different application types. Depending on the application criticality, snapshot frequency, retention, and cross-region copy values differ. For different snapshot frequencies, create unique key-value pairs. The following table shows different RPO / RTO options used for the different application environments.

App – EnvironmentCritical Production AppProductionDev
RPO1 hour24 hours1 week
Snapshot policy namehourlydailyweekly
Resource tag key: valueDLMSHourly: YesDLMSDaily: YesDLMSWeekly: Yes
Snapshot retention24 hours7 days30 days
Enable Fast Snapshot RestoreYesNoNo
Cross-Region copyYesNoNo
Cross-Region copy retention2 daysNoNo
Sample policy options for different application tiers

Create Amazon DLM policy

In my Lab environment, I have one EC2 instance running on the us-east-2 region.

EC2 Instance running

1. From the AWS console – > Navigate to EC2 and then select Lifecycle Manager under the Elastic Block Store. Select the policy type as EBS-backed AMI policy and click “Next step”

DLM – EBS Backed AMI policy

2. Enter the pre-defined resource tags. In my case, I have updated “DLMShourly: Yes”.

DLM – Policy Creation – Target resource tags

3. Enter the policy description. If you want to choose a specific IAM role, you can select it here.

Policy Description and IAM role – Amazon DLM

4. Here is the option to choose the policy status and snapshot option. (To reboot the instance or not during the EBS snapshot)

Policy status – Instance reboot – Amazon DLM

5. Define the snapshot schedule name and snapshot frequency. I have also defined retention here.

Amazon DLM – Schedule details

6. Configure AMI deprecation and Enable cross-region snapshots for disaster recovery.

Deprecate AMI and Enable Cross-Region Copy

7. Select the target DR region details for instance recovery.

Target Region and KMS

8. Review the policy settings and create a policy.

Review Policy settings – Amazon DLM
Review Policy – Amazon DLM

Verify our work:

As we have defined in the Amazon DLM, based on the resource tags, it will pick the resources and takes the snapshot for every hour. It will also convert the snapshot to AMI and copies to targetted DR region. Let’s check for the new AMI on the current region (us-east-2 / Ohio) and target region after a couple of hours. Once you have the AMI, you can launch new instances from that. Kindly note, that the DLM AMI policy will take snapshots for both OS and data disks.

Snapshot in us-east-2 – Primary region

On target region (us-east-1 – N. Virginia )

If you want to test the cross-region snapshot, you can launch it from the AMI and validate it.

DR – target region – us-east-1 – DLM

Conclution

Amazon DLM helps you manage your EBS resources efficiently by automating the lifecycle of Amazon EBS snapshots and EBS-backed AMIs. It is reducing costs and management complexity. You can protect valuable data by enforcing a regular backup schedule, in addition, to reducing storage costs by deleting outdated backups by enabling the AMI depreciation.  In the next article, we will see how to monitor the EBS-backed AMI using AWS native tools. Hope this article is informative to you.

Exit mobile version