📣 Limited offer: subscribe to cloudonaut plus, get a t-shirt for free

📣 Limited offer: free cloudonaut t-shirt

New CloudFormation Template - Backing up DynamoDB the easy way

Michael Wittig – 08 Aug 2017

DynamoDB is an easy-to-use NoSQL database available only on AWS. It comes with many useful features such:

  • Time-to-live for items
  • Secondary indexes
  • Scalable read and write throughput
  • Streams that contain all changes of a table

Unfortunately, there is no backup feature. You might say:

But DynamoDB replicates my data. The durability guarantees are super high. I will never lose my data. I can even replicate my data cross region

But what if your application has a bug and updates many items in a way that corrupts your data, or what if your cleanup script deletes the wrong items? You can not revert changes easily in DynamoDB. You need a backup in that case!

One of the solutions is to run a job on an EMR cluster that does the backup. But this is a multi-step process:

Special offer: cloudonaut t-shirt

Do you love our blog posts and podcast episodes? Unlock our weekly videos and online events by subscribing to cloudonaut plus.

Special offer: Join cloudonaut plus before November 30th, and we will send you a cloudonaut t-shirt for free.

Subscribe now!
  1. Create an EMR cluster
  2. Wait until the cluster is ready
  3. Run the backup job
  4. Wait until the job is completed, retry if necessary
  5. Terminate the EMR cluster
  6. Wait until the cluster is terminated

Luckily, Data Pipeline is a service that can do the orchestration work for you. The Data Pipeline documentation has examples to backup and restore a DynmoDB table.

The only unsolved problem is: How to setup the Data Pipeline? My answer is CloudFormation. I authored a template to backup a DynamoDB table. The template contains the data pipeline, S3 buckets for logs and the backups, and also the glue to alert you if the backup fails. The following figure shows the pipeline definition:

Data Pipeline to backup a DynamoDB table

If you want to setup a CloudFormation stack to backup a DynamoDB table, just follow the steps in the Free Template for AWS CloudFormation documentation.

One downside of this solution is that you have to spin up an EMR cluster for each table that you backup. A cluster consists of one master and one core node, e.g. of type m4.large. In us-east-1 this means 2 $0.10 (assuming the backup completes within one hour). Additionally, you pay for EMR 2 $0.03 (also assuming the backup ti finish in under 1 hour). In total, you spend $0.26 per table per backup.

Michael Wittig

Michael Wittig

I’m an independent consultant, technical writer, and programming founder. All these activities have to do with AWS. I’m writing this blog and all other projects together with my brother Andreas.

In 2009, we joined the same company as software developers. Three years later, we were looking for a way to deploy our software—an online banking platform—in an agile way. We got excited about the possibilities in the cloud and the DevOps movement. It’s no wonder we ended up migrating the whole infrastructure of Tullius Walden Bank to AWS. This was a first in the finance industry, at least in Germany! Since 2015, we have accelerated the cloud journeys of startups, mid-sized companies, and enterprises. We have penned books like Amazon Web Services in Action and Rapid Docker on AWS, we regularly update our blog, and we are contributing to the Open Source community. Besides running a 2-headed consultancy, we are entrepreneurs building Software-as-a-Service products.

We are available for projects.

You can contact me via Email, Twitter, and LinkedIn.

Briefcase icon
Hire me