You can use
mongorestore to seed MongoDB Atlas
cluster with data from an existing MongoDB standalone or replica set.
For guidance on seeding data from an existing MongoDB sharded cluster,
contact Atlas support by clicking Support in the
left-hand navigation of the Atlas UI.
To ensure a completely up-to-date migration, schedule a maintenance
window where you can stop all writes to your source cluster.
Any write operations issued to the source cluster after the
mongodump portion of the procedure completes
are not migrated to the target cluster.
You must cut-over your applications to the target Atlas cluster
mongorestore completes the
data restoration before resuming write operations.
See Connect to a Cluster for complete
documentation on connecting to a Atlas cluster.
The total amount of downtime required depends on factors such as the size of data being migrated and the network connection between your source cluster and Atlas. If you have questions or concerns about extended downtime, contact Atlas support by clicking Support from the left-hand navigation of the Atlas UI.
Atlas fully manages database user creation. If the source
cluster enforces authentication,
--nsExclude to exclude the
admin.system.* namespace. You cannot migrate any existing user or
role information to Atlas.
For the target Atlas cluster, create the appropriate database users for supporting your application's usage patterns. Update your applications as part of the cut-over procedure to use the new database users. See Configure Database Users for complete documentation on database user management.
Consider executing this procedure during non-peak system usage, or during a scheduled maintenance window. If the source is a replica set, you can run this procedure from the host of a secondary member. After stopping writes to the cluster, allow the secondary to catch up to the primary before starting this procedure.
For guidance on addressing persistent broken pipe errors, contact Atlas support by clicking Support from the left-hand navigation of the Atlas UI.
Optional: Create a database user in the source replica set.¶
If your source cluster doesn't enforce authentication, skip this step.
If the source deployment enforces authentication, you must provide a database user with privileges to read any database as part of this procedure. To learn more about database user privileges, see MongoDB Role-Based Access Control.
If no such user exists, create a user in your source MongoDB replica
set with the backup
role on the
Based on the type of connection string you use, copy one of the following templates to into your preferred text editor:
To connect to Atlas clusters, we recommend you connect with a DNS seed list connection string using the
mongodump --uri "mongodb://username:firstname.lastname@example.org:<Port>,mongodb1.example.com:<Port1>,mongodb2.example.com:<Port2>/?replicaSet=<ReplicaSetName>&authSource=admin" \ --archive
Replace the host examples with the information for your replica set members. Replace
<ReplicaSetName> with the name of the source replica set.
For standalone deployments, exclude
replicaSet=<ReplicaSetName> and specify the hostname of the standalone deployment only. For example,
If your password contains special characters, it must be percent-encoded.
Do not run this command yet. Proceed to the next step once you have modified the template.
Set up database user in the target Atlas cluster.¶
If no such user exists, create the user:
- If it is not already displayed, select your desired organization from the Organizations menu in the navigation bar.
- Click Access Manager in the sidebar, or click Access Manager in the navigation bar, then click your organization.
- Click Add New Database User.
- Add an Atlas admin user.
To learn more about user management, see Configure Database Users.
Navigate to the Clusters page for your project.¶
- If it is not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
- If it is not already displayed, select your desired project from the Projects menu in the navigation bar.
- If the Clusters page is not already displayed, click Clusters in the sidebar.
Choose Command Line Tools for your desired cluster.¶
From the menu for the cluster, click Command Line Tools.
Retrieve and modify the
mongorestore connection template.¶
The Binary Import and Export Tools section of the
Command Line Tools tab displays a copyable template with
the minimum required options for connecting
mongorestore to your
The template includes placeholder values for certain options. Copy and paste the template into your preferred text editor and make the following modifications:
password: replace this with the password for the user specified in
username. The template includes a database user for the project as the
username. If you want to authenticate as a different user, replace the value of
usernameand specify the password for that user in
--nsExcludeand set its value to
Based on the type of connection string you use, your template should resemble one of the following commands:
mongorestore --uri "mongodb://username:email@example.com:27017,01.foo.mongodb.net:27017,02.foo.mongodb.net:27017/?replicaSet=myRepl&authSource=admin" \ --archive \ --ssl \ --nsExclude "admin.system.*"
In your preferred text editor, use the pipe
| operator to
mongorestore commands. Based on the type of connection string you use, the final
command should resemble one of the following:
mongodump --uri "mongodb://username:firstname.lastname@example.org:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?replicaSet=sourceRS&authSource=admin" \ --archive \ | \ mongorestore --uri "mongodb://username:email@example.com:27017,01.foo.mongodb.net:27017,02.foo.mongodb.net:27017/?replicaSet=myAtlasRS&authSource=admin" \ --archive \ --ssl \ --nsExclude "admin.system.*"
Run the completed command from a terminal or shell connected to a host machine on your source cluster.
You must update your applications to point to the Atlas cluster before resuming write operations. To learn how to connect applications to Atlas, see Connect via Driver.