{"id":17750,"date":"2026-10-26T18:54:44","date_gmt":"2026-10-26T13:24:44","guid":{"rendered":"https:\/\/www.skynats.com\/blog\/?p=17750"},"modified":"2026-10-26T18:54:44","modified_gmt":"2026-10-26T13:24:44","slug":"mongodb-to-amazon-documentdb-migration","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/mongodb-to-amazon-documentdb-migration\/","title":{"rendered":"MongoDB to Amazon DocumentDB Migration: A Complete Step-by-Step Guide"},"content":{"rendered":"<h2><b>Introduction<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Migrating from a self-managed MongoDB database to Amazon DocumentDB requires careful planning, data extraction, secure file transfer, namespace mapping, restoration, and validation.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This guide explains how to migrate the <code>sourcedb<\/code> database from a self-managed MongoDB server to an Amazon DocumentDB cluster, using <span style=\"color: #000000;\"><code>destinationdb<\/code><\/span> as the destination database..<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The migration uses MongoDB Database Tools (mongodump and mongorestore), rsync for transferring backup files, TLS for encrypted connectivity, and a dry-run restore to validate the migration command before making changes.<\/span><\/p>\n<h2>What Is Amazon DocumentDB?<\/h2>\n<p>Amazon DocumentDB is a fully managed document database service from Amazon Web Services that supports MongoDB-compatible APIs.<\/p>\n<p>It allows developers to use many familiar MongoDB drivers, tools, and document-oriented data structures while AWS manages infrastructure-related operations.<\/p>\n<p>Amazon DocumentDB provides capabilities such as managed backups, high availability, monitoring, and storage management.<\/p>\n<p>However, Amazon DocumentDB is not identical to MongoDB. Feature compatibility, supported operators, index behavior, and application functionality can differ depending on the target engine version.<\/p>\n<p><span style=\"color: #808080;\"><a style=\"color: #808080;\" href=\"https:\/\/aws.amazon.com\/\" target=\"_blank\" rel=\"noopener\">AWS<\/a><\/span> maintains an official compatibility reference that should be reviewed before migration<\/p>\n<h2>Why Migrate MongoDB to Amazon DocumentDB?<\/h2>\n<p>Organizations may consider migrating MongoDB to Amazon DocumentDB to simplify database operations and take advantage of AWS-managed infrastructure.<\/p>\n<p>Potential benefits include:<\/p>\n<ul>\n<li>\n<div>\n<div>\n<p>Reduced infrastructure management: Less responsibility for manually maintaining database infrastructure.<\/p>\n<\/div>\n<\/div>\n<\/li>\n<li>\n<div>\n<div>\n<p>High availability: Managed deployment options with replication and failover capabilities.<\/p>\n<\/div>\n<\/div>\n<\/li>\n<li>\n<div>\n<div>\n<p>Automated backups: AWS-managed backup and recovery functionality.<\/p>\n<\/div>\n<\/div>\n<\/li>\n<li>\n<div>\n<div>\n<p>AWS integration: Connectivity with services such as Amazon EC2, AWS IAM, Amazon CloudWatch, and AWS networking.<\/p>\n<\/div>\n<\/div>\n<\/li>\n<li>\n<div>\n<div>\n<p>Operational scalability: Managed infrastructure options to accommodate changing workloads.<\/p>\n<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<p>These benefits should be evaluated against application compatibility, performance requirements, and projected costs.<\/p>\n<h3><b>Migration overview<\/b><\/h3>\n<p><b>Source environment<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Database: sourcedb<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">MongoDB host: localhost<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Port: 27017<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Backup directory: \/usr\/local\/src\/migrate\/dump\/<\/span><\/li>\n<\/ul>\n<p><b>Destination environment<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Amazon DocumentDB cluster: destination-db<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Destination database: destinationdb<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Backup staging directory: \/var\/www\/mongorestore\/dump\/<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">TLS certificate bundle: \/root\/global-bundle.pem<\/span><\/li>\n<\/ul>\n<h2><b>Prerequisites<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Before starting the migration, confirm the following.<\/span><\/p>\n<h3><b>Source MongoDB<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The source MongoDB instance is running.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The migration account has permission to read the required database and collections.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">MongoDB Database Tools are installed.<\/span><\/li>\n<\/ul>\n<h3><b>Destination server<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">SSH access to the source server is available.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The destination server can reach the Amazon DocumentDB cluster over TCP port 27017.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The destination server has the appropriate DocumentDB CA bundle.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">MongoDB Database Tools are compatible with the target Amazon DocumentDB environment.<\/span><\/li>\n<\/ul>\n<h2><b>Create a MongoDB dump on the source server<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Log in to the source MongoDB server and execute the following command.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">mongodump\u00a0 &#8211;host=&#8221;localhost&#8221; &#8211;port=27017 &#8211;username=&#8221;sourcedbuser&#8221;\u00a0 &#8211;password &#8211;authenticationDatabase=&#8221;sourcedb&#8221; &#8211;db=&#8221;sourcedb&#8221; &#8211;out=&#8221;\/usr\/local\/src\/migrate\/dump&#8221;<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">The command prompts for the password.<\/span><\/p>\n<h3><b>Explanation of the parameters<\/b><\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>Parameter<\/b><\/td>\n<td><b>Purpose<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&#8211;host<\/span><\/td>\n<td><span style=\"font-weight: 400;\">MongoDB server hostname<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&#8211;port<\/span><\/td>\n<td><span style=\"font-weight: 400;\">MongoDB connection port<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&#8211;username<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Source database username<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&#8211;password<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Prompts for the password<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&#8211;authenticationDatabase<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Database where the user authenticates<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&#8211;db<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Database to back up<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&#8211;out<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Directory where dump files are written<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><b>Expected directory structure<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">After a successful dump, the directory should resemble:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\/usr\/local\/src\/migrate\/<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u2514\u2500\u2500 dump\/<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u2514\u2500\u2500 sourcedb\/<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u251c\u2500\u2500 collection1.bson<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u251c\u2500\u2500 collection1.metadata.json<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u251c\u2500\u2500 collection2.bson<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u251c\u2500\u2500 collection2.metadata.json<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u2514\u2500\u2500 &#8230;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Actual filenames depend on the collections in the database. The BSON files contain the document data, while the metadata files can contain collection options and index definitions.<\/span><\/p>\n<h2><b>Transfer the dump to the destination server<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">On the destination server, ensure the target directory exists and use <code>rsync<\/code> to transfer the MongoDB backup securely from the source server.<br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0command:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">rsync -avz root@sourceip:\/usr\/local\/src\/migrate\/dump\/\u00a0 \/var\/www\/mongorestore\/dump\/<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><b>Prepare the Amazon DocumentDB destination<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Verify the TLS certificate bundle. Confirm that the certificate bundle exists:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">ls -l \/root\/global-bundle.pem<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Use the current AWS-provided CA bundle appropriate for Amazon DocumentDB. Keep the bundle readable by the migration account and do not disable certificate verification to bypass TLS errors.<\/span><\/p>\n<h3><b>Verify database authentication<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Use the target administrator account and a TLS-enabled connection:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">mongosh &#8211;host=&#8221;<\/span><span style=\"font-weight: 400;\">destination-db.cluster-cbpxrmfy65hz.ap-south-1.docdb.amazonaws.com:27017<\/span><span style=\"font-weight: 400;\">&#8221; &#8211;username=&#8221;admin00000&#8243; &#8211;password &#8211;authenticationDatabase=&#8221;admin&#8221;\u00a0 &#8211;tls &#8211;tlsCAFile=&#8221;\/root\/global-bundle.pem&#8221; &#8211;retryWrites=false<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Enter the password when prompted. After connecting, check the available databases and confirm that the account has the permissions required for the restore.<\/span><\/p>\n<h2><b>Map the source database to the destination database<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">The source database is named sourcedb, while the destination database must be named destinationdb. The following namespace mapping handles that change:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">&#8211;nsFrom=&#8221;sourcedb.*&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211;nsTo=&#8221;destinationdb.*&#8221;<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">The wildcard preserves each collection name while changing its database name. This mapping does not rename the individual collections or transform document fields. It only changes the namespaces used by the restore operation.<\/span><\/p>\n<h2><b>Perform a dry-run restore<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Before modifying production data, execute a dry run on destination server.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">mongorestore &#8211;host=&#8221;<\/span><span style=\"font-weight: 400;\">destination-db.cluster-cbpxrmfy65hz.ap-south-1.docdb.amazonaws.com:27017<\/span><span style=\"font-weight: 400;\">&#8221; &#8211;username=&#8221;admin00000&#8243; &#8211;password &#8211;tls &#8211;tlsCAFile=&#8221;\/root\/global-bundle.pem&#8221; &#8211;authenticationDatabase=&#8221;admin&#8221; &#8211;retryWrites=false &#8211;nsFrom=&#8221;sourcedb.*&#8221; &#8211;nsTo=&#8221;destinationdb.*&#8221; &#8211;drop &#8211;dryRun &#8220;\/var\/www\/mongorestore\/dump\/&#8221;<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Enter the destination password when prompted.<\/span> <span style=\"font-weight: 400;\">A dry run checks and reports the restore plan without importing the documents. The &#8211;drop option is included to document the intended final restore behavior, but it does not actually drop collections during a supported dry run.<\/span><\/p>\n<h2><b>Restore the data into Amazon DocumentDB<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Once the dry run, backup integrity checks, target connectivity, and change-control approvals are complete, run the actual restore. The following command omits &#8211;dryRun, so it will perform real changes:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">mongorestore &#8211;host=&#8221;<\/span><span style=\"font-weight: 400;\">destination-db.cluster-cbpxrmfy65hz.ap-south-1.docdb.amazonaws.com:27017<\/span><span style=\"font-weight: 400;\">&#8221; &#8211;username=&#8221;admin00000&#8243; &#8211;password &#8211;tls &#8211;tlsCAFile=&#8221;\/root\/global-bundle.pem&#8221; &#8211;authenticationDatabase=&#8221;admin&#8221; &#8211;retryWrites=false &#8211;nsFrom=&#8221;sourcedb.*&#8221; &#8211;nsTo=&#8221;destinationdb.*&#8221; &#8211;drop &#8220;\/var\/www\/mongorestore\/dump\/&#8221;<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Enter the password when prompted.<\/span><\/p>\n<h2><b>Validate the restored database<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">A completed mongorestore command does not by itself prove that the migration is correct. Validate the result at multiple levels.<\/span><\/p>\n<h3><b>Verify the destination database<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Connect to Amazon DocumentDB using mongosh:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">mongosh &#8211;host=&#8221;<\/span><span style=\"font-weight: 400;\">destination-db.cluster-cbpxrmfy65hz.ap-south-1.docdb.amazonaws.com:27017<\/span><span style=\"font-weight: 400;\">&#8221; &#8211;username=&#8221;admin00000&#8243; &#8211;password &#8211;authenticationDatabase=&#8221;admin&#8221;\u00a0 &#8211;tls &#8211;tlsCAFile=&#8221;\/root\/global-bundle.pem&#8221; &#8211;retryWrites=false<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Then run:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">show dbs<\/span><\/p>\n<p><span style=\"font-weight: 400;\">use destinationdb<\/span><\/p>\n<p><span style=\"font-weight: 400;\">show collections<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Confirm that the expected collections exist.<\/span><\/p>\n<h3><b>Validate application functionality<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">After database-level checks, verify the application against the destination database.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Test:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Database authentication and connection pooling.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Reads and writes for representative application workflows.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Critical queries and aggregation pipelines.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Background jobs, scheduled tasks, and event processing.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Error logs and application health checks.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Keep the source available and retain a rollback plan until the destination has passed the required validation.<\/span><\/p>\n<h2><b>Conclusion<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Migrating MongoDB to Amazon DocumentDB using mongodump, rsync, and mongorestore is a practical approach for controlled migrations.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The essential stages are to create a reliable source backup, transfer it securely, map sourcedb to destinationdb, validate the restore plan, execute the restore, and verify data integrity and application compatibility.<\/span><\/p>\n<div>\n<h2>Need Expert Help Migrating MongoDB to Amazon DocumentDB?<\/h2>\n<p>A successful <a href=\"https:\/\/www.skynats.com\/blog\/how-to-migrate-mongodb-to-amazon-documentdb\/\">MongoDB migration<\/a> requires careful planning, compatibility checks, secure data transfer, and thorough validation. Businesses planning to move their databases to AWS can work with <a href=\"https:\/\/www.skynats.com\/\">Skynats<\/a> for migration planning, <a href=\"https:\/\/www.skynats.com\/cloud-management\">cloud infrastructure management<\/a>, and post-migration support.<\/p>\n<p><a href=\"https:\/\/www.skynats.com\/aws-management-services\">Explore AWS Migration Support<\/a><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Migrating from a self-managed MongoDB database to Amazon DocumentDB requires careful planning, data extraction, secure file transfer, namespace mapping, restoration, and validation. This guide explains how to migrate the sourcedb database from a self-managed MongoDB server to an Amazon DocumentDB cluster, using destinationdb as the destination database.. The migration uses MongoDB Database Tools (mongodump [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-17750","post","type-post","status-publish","format-standard","hentry","category-blog"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/17750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=17750"}],"version-history":[{"count":1,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/17750\/revisions"}],"predecessor-version":[{"id":17752,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/17750\/revisions\/17752"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=17750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=17750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=17750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}