DocumentDB, a popular NoSQL document database, provides a robust data import and export mechanism. One of the key features is the ability to restore data from a MongoDB dump using the mongorestore command. In this paper, we will explore the concept of mongorestore in DocumentDB, its benefits, and provide a step-by-step guide on how to use it.
mongorestore --uri="mongodb://<DocumentDB_account_name>:<password>@<DocumentDB_account_name>.documents.azure.com:10255/" --db <database_name> --collection <collection_name> --archive dump.gz --gzip
mongorestore is a command-line utility that allows users to restore data from a MongoDB dump into a DocumentDB or MongoDB database. The tool reads the MongoDB dump files, created using the mongodump command, and inserts the data into the target database.
While mongorestore generally works, keep these functional differences in mind: Mongorestore 4.2 can work with AWS DocumentDB 4.0?
: Creating indexes during restoration can be slow. For very large datasets, consider creating the indexes on DocumentDB before the data load using the Amazon DocumentDB Index Tool and then running mongorestore with the --noIndexRestore flag.
: It is recommended to use MongoDB Database Tools that match the version of your target DocumentDB cluster (e.g., use 4.0 tools for a DocumentDB 4.0 cluster). How to Use mongorestore with DocumentDB
In this paper, we have explored the concept of mongorestore in DocumentDB, its benefits, and provided a step-by-step guide on how to use it. By leveraging mongorestore , users can easily migrate data from MongoDB to DocumentDB, recover data in case of loss or corruption, and quickly restore test or development environments.
Amazon DocumentDB (with MongoDB compatibility) is a fast, scalable, fully managed database service that mimics the MongoDB 4.0 and 5.0 wire protocols. While it aims to be a drop-in replacement for MongoDB, subtle differences exist. One of the most common migration and backup-recovery tasks is restoring data using mongorestore — the standard utility from MongoDB’s database tools. This essay explores how to effectively use mongorestore with DocumentDB, highlighting compatibility nuances, operational steps, and performance considerations.
DocumentDB uses SCRAM (default) or AWS IAM authentication. For SCRAM, pass --username and --password . For IAM, you need a separate plugin ( --authenticationMechanism MONGODB-AWS ) — available in mongorestore version 4.4+.