For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Load Data into an Atlas Infinite Cluster

To load your own data into an Atlas Infinite cluster, use one of the following methods:

  • mongodump and mongorestore: mongodump creates a binary export of the data from an existing MongoDB standalone or replica set, including an Atlas Core cluster, and mongorestore loads the data into an Atlas Infinite cluster. Use this method when your source data is in a MongoDB deployment. To learn how, see Restore Data from a MongoDB Deployment.

  • mongoimport: mongoimport loads documents from a JSON or CSV file into an Atlas Infinite cluster. Use this method when your source data is in a file external to MongoDB. The file can come from mongoexport or from a third-party export tool. To learn how, see Import Data from a JSON or CSV File.

  • Bulk write operations: MongoDB database methods write batches of documents into an Atlas Infinite cluster. Use this method when you generate or transform the documents yourself from an application, mongosh, Atlas UI, or another interface. To learn how, see Write Data That You Generate.

Each of these methods consumes write capacity on the destination Atlas Infinite cluster. To limit the effect on your applications, run large data loads during non-peak system usage or a scheduled maintenance window.

Complete the following prerequisites:

mongodump creates a binary export of an existing MongoDB standalone or replica set, and mongorestore loads that export into an Atlas Infinite cluster. The export includes data, metadata, and indexes from the source deployment. For guidance on copying data from an existing MongoDB sharded cluster, see Request Support.

You can also use this procedure to migrate data from a Free cluster or Flex cluster on Atlas Core to a dedicated cluster on Atlas Infinite. To scale a Free cluster or Flex cluster in place instead of migrating data, see Scale a Free or Flex Cluster to a Dedicated Cluster.

This procedure requires downtime. Stop writes to your source deployment, run mongodump and mongorestore, then cut over your applications to the Atlas Infinite cluster.

Before you run this procedure, consider the following behaviors:

  • Data consistency: To avoid losing data, pause writes to your source deployment before you run mongodump. If you run mongodump from a secondary member, pause writes and then wait for the secondary to catch up to the primary before you start the dump.

  • Users and roles: Atlas manages database users, so mongorestore can't migrate existing database users or roles to the destination cluster. Create the database users that your applications need in the destination Atlas Infinite cluster. To learn more, see Configure Database Users.

  • Excluded namespaces: The admin and config directories in the dump hold user information that mongorestore can't add to an Atlas Infinite cluster, so the procedure excludes admin.* and config.*.

  • Host resources: mongodump runs on a host with network access to your source deployment, and mongorestore runs on a host with access to the archive file and network access to your destination deployment. Both tools use CPU and memory on the host, which can affect that host's performance.

1

If the source deployment enforces authentication, mongodump must authenticate as a database user that can read every database you migrate. The backup role on the admin database grants these privileges.

If no such user exists in your source deployment, create one. To learn how to create and manage database users, see the following page for your deployment type:

2

mongorestore must authenticate as a database user that can write to every database you migrate. The Atlas admin role on the destination Atlas Infinite cluster grants these privileges.

If no such user exists in your destination Atlas Infinite cluster, create one. To learn how to create and manage database users in Atlas, see Configure Database Users.

3

Ensure that the host where you run mongodump and mongorestore can reach both deployments:

  • Add the host to the IP access list for the project that contains your destination Atlas Infinite cluster. To learn how to add a host to an IP access list, see Configure IP Access List Entries.

  • If your source deployment is an Atlas Core cluster in a different project, add the host to that project's IP access list as well. If your source deployment is self-managed, configure its firewall to accept connections from the host. To learn more, see Network and Configuration Hardening.

If you set up VPC peering, you can add the peer's VPC CIDR block or a subnet, or the peer VPC's security group to the IP access list. To learn more, see IP Access List.

4
  1. Assemble the mongodump command.

    The following mongodump command template connects to a source replica set or standalone cluster using its connection string, and outputs an archive of the dump to a file.

    Copy the template into your preferred text editor and replace the <connectionString> placeholder with the connection string for your source deployment, and <fileName> with the name of the archive file to create.

    mongodump --uri "<connectionString>" --archive=<fileName>.archive

    To learn how to construct a connection string for your source deployment, see Connection Strings.

    Note

    If using mongodump or mongorestore on Ubuntu 18.04, you may experience a cannot unmarshal DNS error message when using SRV connection strings (in the form mongodb+srv://) with the --uri option. If so, use one of the following options instead:

    • the --uri option with a non-SRV connection string (in the form mongodb://)

    • the --host option to specify the host to connect to directly

  2. Run the completed command from a terminal or command prompt on a host that has network access to your source deployment.

    Example

    The following mongodump command connects to a source Atlas Core cluster using an SRV connection string, which contains the username (mySourceUsername) and password (mySourcePassword) for a database user with the backup role on the admin database. The command outputs an archive of the dump to a file named mongodump.archive in the current working directory.

    mongodump --uri "mongodb+srv://mySourceUsername:mySourcePassword@cluster0.example.mongodb.net" \
    --archive="mongodump.archive"
5
  1. Assemble the mongorestore command.

    The following mongorestore command template connects to your destination Atlas Infinite cluster using its connection string and restores the archive created by mongodump. It uses --nsExclude to exclude the admin and config databases, which Atlas manages.

    Copy the template into your preferred text editor and replace the following placeholders with the appropriate values:

    • <connectionString>: replace this with the SRV connection string for your destination Atlas Infinite cluster. To retrieve or construct a connection string for your destination cluster, see Connection Strings.

      Include the username and password for a database user with the Atlas admin role in the connection string.

    • <filePath>: replace this with the path to the archive file created by mongodump.

    Note

    If the username or password includes the following characters, those characters must be converted using percent encoding:

    $ : / ? # [ ] @
    mongorestore --uri "<connectionString>" \
    --archive="<filePath>" \
    --nsExclude "admin.*" \
    --nsExclude "config.*"
  2. Run the completed command from a terminal or command prompt on a host that has access to the archive file created by mongodump.

    Example

    The following mongorestore command connects to an Atlas Infinite cluster using an SRV connection string, which contains the username (myDestinationUsername) and password (myDestinationPassword) for a database user with the Atlas admin role. The command restores the archive at mongodump.archive created by mongodump, excluding the admin and config databases.

    mongorestore --uri "mongodb+srv://myDestinationUsername:myDestinationPassword@cluster0.example.mongodb.net" \
    --archive="mongodump.archive" \
    --nsExclude "admin.*" \
    --nsExclude "config.*"
6

After the migration is complete, connect to your Atlas Infinite cluster and verify that the data has been migrated successfully. You can run queries to check the presence of your collections and documents in the destination cluster.

7

After verifying the migration, update your applications to connect to the Atlas Infinite cluster instead of the source deployment. Ensure that you use the correct connection string and credentials for the Atlas Infinite cluster.

mongoimport reads a JSON or CSV file and inserts each record into a collection in an Atlas Infinite cluster. The file can come from a third-party export tool. To restore data from a MongoDB deployment into an Atlas Infinite cluster, see Restore Data from a MongoDB Deployment.

Before you run this procedure, consider the following behaviors:

  • Extended JSON: mongoimport uses strict mode representation for certain BSON types.

  • Documents only: Unlike mongorestore, mongoimport loads documents only, not collection options or index definitions. Create indexes on the destination Atlas Infinite cluster after the import completes.

  • Host resources: mongoimport runs on the host that holds your file and uses CPU and memory on that host.

  • Other interfaces: To load a file without the command line, use MongoDB Compass, which imports JSON and CSV files, or the Atlas UI, which inserts JSON documents that you paste or type.

1
  1. If it's not already displayed, select the organization that contains your project from the Organizations menu in the navigation bar.

  2. If it's not already displayed, select your project from the Projects menu in the navigation bar.

  3. In the sidebar, click Database & Network Access under the Security heading.

The Database & Network Access page displays after you complete the preceding steps.

2

To run mongoimport to write to an Atlas cluster, you must specify a database user that has readWrite privileges in the database into which to import data. For example, a user with Atlas admin role provides these privileges.

If no such user exists, create the user:

  1. If it isn't already displayed, click the Database Users tab.

  2. Click Add New Database User.

  3. Add an Atlas admin user.

3
  1. If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.

  2. If it's not already displayed, select your desired project from the Projects menu in the navigation bar.

  3. In the sidebar, click Clusters under the Database heading.

The Clusters page displays.

4

Click Connect for the Atlas cluster into which you want to migrate data.

5

If the host where you will run mongoimport is not in the IP Access List, update the list. You can specify either:

  • The public IP address of the server on which mongoimport will run, or

  • If set up for VPC peering, either the peer's VPC CIDR block (or a subnet) or the peer VPC's Security Group, if you chose AWS as your cloud provider.

6

You can connect to your Atlas cluster using its connection string URI. In the connect dialog box perform the following steps:

  1. Click Drivers.

  2. Copy the connection string found in step 1.

  3. Replace PASSWORD with the password for the root user, and DATABASE with the name of the database to which you wish to connect.

    Important

    You must escape any instances of the @ character in the provided <PASSWORD>. For example, p@ssword should be p%40ssword.

This connection string is specified to mongoimport in the --uri option.

When using --host, if the Atlas cluster is a replica set you must also retrieve the replica set name. For example:

myAtlasRS/atlas-host1:27017,atlas-host2:27017,atlas-host3:27017
7

Bulk write operations send many writes to an Atlas Infinite cluster in a single request, which reduces network round trips and increases write throughput. Choose this method to write documents that you generate into an Atlas Infinite cluster, instead of copying data from an existing deployment or file.

Before you run this procedure, consider the following behaviors:

  • Bulk write behavior: The write operations and options that you specify in a bulk write request determine how MongoDB orders write operations, handles errors, and reports results for a request. To learn how these choices affect bulk write behavior, see the bulkWrite() reference page.

  • Other interfaces: To write a small number of documents without batching logic, use insertMany() or insertOne() from mongosh or a MongoDB driver, or the Atlas UI, which inserts JSON documents that you paste or type.

1

To run the bulk write operations in this procedure, connect to your cluster with mongosh. To learn how, see Connect to an Atlas Cluster.

You can also run bulk write operations from application code with a MongoDB driver, from the Atlas UI, or from any other interface that connects to your cluster. To learn about the equivalent operations in each interface, see Bulk Write Operations.

2

To write to a single collection, run bulkWrite(). To learn more about write operation types and bulk write options, see bulkWrite().

For example, the following command inserts two documents into the inventory collection:

db.inventory.bulkWrite( [
{ insertOne: { document: {
_id: ObjectId("68b1c2d3e4f5a6b7c8d9e0f1"),
item: "notebook",
qty: 50
} } },
{ insertOne: { document: {
_id: ObjectId("68b1c2d3e4f5a6b7c8d9e0f2"),
item: "pencil",
qty: 100
} } }
] )

To write to multiple collections or databases in one request, run bulkWrite() and specify the namespace for each operation. For example, the following command inserts one document into the sales.inventory collection and one document into the supplies.inventory collection:

db.getMongo().bulkWrite( [
{
namespace: "sales.inventory",
name: "insertOne",
document: { item: "notebook", qty: 50 }
},
{
namespace: "supplies.inventory",
name: "insertOne",
document: { item: "pencil", qty: 100 }
}
] )

By default, bulk write operations run in order and stop at the first error. To learn how to configure run order, see Execution of Operations.

3

Review the counts that the operation returns and confirm the document count in each target collection. To learn more, see Output.

To learn how to handle errors for bulk write operations, see Error Handling.

Atlas Infinite has a full list of public preview limitations in Public Preview Availability. The following limitations apply when you load data into an Atlas Infinite cluster:

  • No oplog replay: Atlas Infinite doesn't support oplog replay. Don't use the mongodump --oplog option or the mongorestore --oplogReplay option with Atlas Infinite clusters.

  • Queryable Encryption and Client-Side Field Level Encryption: You can't use mongodump or mongorestore with a collection that uses Queryable Encryption or Client-Side Field Level Encryption.

  • Cross-edition live migration and restore: Atlas Infinite doesn't support live migration or backup and restore between Atlas Core and Atlas Infinite clusters. Architectural differences between the two deployment options make snapshots and live migrations incompatible.