EBS Volume Backup and Replication

Summary

In this post, we will look at a solution for backing up EBS volumes and copying them to a disaster recovery region.

Solution Overview

For this solution, we will be using Data Lifecycle Manager for EBS to snapshot EBS volumes and replicate to a disaster recovery region. This is a tag-based solution, DLM will trigger based on tags. When a snapshot is created, the replicator lambda copies it to the disaster recovery region.

Getting Started

The source for this solution is available on github. Both Terraform and CloudFormation is provided with this solution.

Installation with Terraform:

// Live region
provider "aws" {
  version = "~> 1.52"
  region  = "us-east-2"
}

// DR region
provider "aws" {
  alias   = "uw2"
  version = "~> 1.52"
  region  = "us-west-2"
}

// Install the backup module
module "backup" {
  source = "github.com/webdevwilson/ebs-dlm-backup-replicate"

  providers = {
    aws    = "aws"
    aws.dr = "aws.uw2"
  }

  replication_region = "us-west-2"
}

Using CloudFormation

Install the templates located in the cfn directory. There is one for the live region and the replication region. The only required parameters are the ReplicationRegion and the number of snapshots to retain, SnapshotRetention.

Wrapping Up

With this solution, you should be able to easily setup a mechanism to replicate your EBS snapshots to a DR region. It uses AWS Data Lifecycle Manager to create the snapshots. Snapshot creation of EBS volumes attached to running instances can be tricky. Be sure to read the Amazon EBS Snapshot Lifecycle documentation to insure this will work for your situation.

Avatar
Kerry Wilson
AWS Certified IQ Expert | Cloud Architect

Coming from a development background, Kerry’s focus is on application development, infrastructure and security automation, and applying agile software development practices to IT operations in the cloud.

Related