AWS Storage Blog

Manage backup and restore of Amazon DocumentDB (with MongoDB compatibility) with AWS Backup

On November 8, 2021, AWS Backup announced support for Amazon DocumentDB (with MongoDB compatibility) clusters, adding to the supported AWS services across compute, storage, and database. Many customers, especially in regulated industries, require centralized management of their data protection and compliance across different AWS services. With this launch, you can centrally manage and govern the data protection of Amazon DocumentDB snapshots alongside other supported AWS services.

Amazon DocumentDB (with MongoDB compatibility) is a scalable, highly durable, and fully managed database service for operating mission-critical MongoDB workloads. Amazon DocumentDB has built-in backups enabled by default with a retention period of one day. Depending on Recovery Point Objective (RPO), you can configure the retention period to be up to 35 days and perform Point-In-Time-Recovery (PITR) restore up to a specific point in time within the retention period. For longer backup retention, you can use AWS Backup to create automated periodic snapshots of your Amazon DocumentDB clusters.

AWS Backup allows you to create and manage your backups across AWS compute, storage, and database services using centralized backup policies. Together with AWS Organizations, AWS Backup enables you to centrally deploy data protection (backup) policies to configure, manage, and govern backup activity across AWS Regions and accounts. With the AWS Backup console or CLI, you can create a single backup policy that centralizes backup and restore for Amazon DocumentDB, across AWS Regions and accounts. AWS Backup’s automated backup schedules and retention policies manage the lifecycle of Amazon DocumentDB snapshots, which were previously managed manually.

In this post, I discuss how to use AWS Backup to schedule automatic backups using a backup plan, create an on-demand backup job for Amazon DocumentDB, and restore a backup to an Amazon DocumentDB cluster.


  1. To create backups using AWS Backup, you need an Amazon DocumentDB cluster. You can use an existing Amazon Document cluster or create a new one.
  1. Configure AWS Backup to manage the Amazon DocumentDB resource type in order to schedule backups for Amazon DocumentDB with the following actions.

On the AWS Backup console, navigate to Settings and ensure that the Status for Amazon DocumentDB is Enabled, indicating that the service is opted in for management by AWS Backup. If not enabled, choose Configure resources to opt in. This is a one-time setup. AWS Backup supports copying backups to other Regions and restoring from those Regions. For the purpose of this post, you should configure AWS Backup in the same Region as your Amazon DocumentDB cluster.

AWS Backup Service opt-in DocumentDB

Schedule backups using a backup plan for Amazon DocumentDB

  1. To schedule automated backups, you will first need to create a backup plan. On the AWS Backup console, navigate to Backup plans and choose Create Backup plan.Create Backup plan
  1. Choose Build a new plan and provide a Backup plan name. Complete the configuration section by providing a Backup rule name with the defaults for remaining fields, and select Create Plan. The backup rule in this plan instructs AWS Backup to perform daily backups to the default backup vault. Every AWS Region in your account has a default backup vault, but you also have the option to create new backup vaults. You can also choose to copy the backup to another Region, if needed.Build new Backup plan for DocumentDB
  1. Now select Assign resources to assign Amazon DocumentDB resources that you want to be automatically backed up defined by the backup plan created in the previous step. You can assign resources using tags or resource IDs. In this post, you are going to assign by resource ID however if you would like to know more about how to assign by tags, refer documentation here.Assign resources
  1. Now populate the Assign resources page by providing the Resource assignment name and selecting the default IAM role. In the Assign resources section, choose assign by Resource ID, select Resource type as DocumentDB and under Cluster ID, choose the Amazon DocumentDB cluster, and select Assign resources. To simplify the process of backing up multiple Amazon DocumentDB clusters, you can assign by “Tags” to assign all Amazon DocumentDB clusters with a matching tag name.Assign resources DocumentDB Clusters

The selected cluster will be backed up every day at 5:00 AM UTC.

Create on-demand backup job for Amazon DocumentDB

  1. On the AWS Backup console, Navigate to Protected resources and choose on Create on-demand backup.Create on-demand backup
  1. Choose Resource type as DocumentDB and select Cluster ID to back up. Use default values for the remaining fields and choose Create on-demand backup.Create on-demand backup DocumentDB Resource type

Choose the backup job ID created from previous step to view details of the job.

Restore an Amazon DocumentDB cluster using AWS Backup

  1. To restore from backup, navigate to Backup vaults and select the Default backup vault or the one you selected while creating your backup plan in step 2 of the “Schedule backups using backup plan for Amazon DocumentDB” section. Select the latest completed backup and choose Restore from the Actions pull down menu.Backup vaults Restore
  1. In the Restore Amazon DocumentDB cluster snapshots, provide the DB cluster identifier for the new cluster, use the default options for the rest, and choose Restore backup. You can optionally choose to use a different cluster parameter group or publish an audit log and a profiler log to Amazon CloudWatch for this cluster. Restore process will create a new cluster with no instances in the same VPC as the source cluster. The restored cluster leverages the same subnets as the source cluster and use the default security group in the VPC.Restore DocumentDB cluster snapshots
  1. The restore job is in running status and can be found under the Restore jobs tab.Restore jobs running

The restore job will create a new Amazon DocumentDB cluster and restore data from the selected cluster identifier (sample cluster) within ten minutes.

  1. Navigate to Amazon DocumentDB Cluster to view the restored cluster.Restored DocumentDB cluster

If you restore Amazon DocumentDB cluster using the AWS Backup console, you will have to add your instances to the cluster post-restore.

  1. To add an instance to query this cluster, select the name of the cluster where the backup was restored and select the Instances Select Create to create an instance in this cluster.Create restored instances
  1. Leave the instance settings with the default values and select Create.Add instances to restored cluster
  2. After the instance has been created, you should see it within the cluster view.DocumentDB Cluster instance restored and available

Cleaning up

To avoid incurring charges, delete the backups created by the backup plan and the on-demand backup job. Also, delete the Amazon DocumentDB cluster restored from the backup. The backup plan can be deleted by following the steps here.


In this post, I showed you how to use AWS Backup to create on-demand backups and schedule automatic backups for Amazon DocumentDB. I also showed how to restore from backups using AWS Backup. AWS Backup provides an automated and centralized service to schedule, monitor, and manage data protection for supported AWS services. Amazon DocumentDB integration to AWS Backup allows you to leverage your existing backup plans and rules to manage Amazon DocumentDB snapshots, making it easier to manage data protection and compliance of your databases and focus on your database applications.

Do you have follow-up questions or feedback? Leave a comment. I’d love to hear your thoughts and suggestions.

Learn more about the services mentioned:

Karthik Vijayraghavan

Karthik Vijayraghavan

Karthik Vijayraghavan is a Senior DocumentDB Specialist Solutions Architect at AWS. He helps customers modernize their applications using NoSQL databases. He enjoys solving customer problems, and is passionate about providing cost effective solutions that perform at scale. Karthik started his career as a developer building web and REST services, with a strong focus on integration with relational databases.