Fix This Page
Navigation

Migrate Data from an M0 (Free Tier) Cluster to a Paid Cluster

On this page

This procedure uses the mongodump and mongorestore tools to migrate data from a Atlas Free Tier cluster to a Atlas Paid Tier cluster.

Considerations

mongodump and mongorestore version

Use the 3.4 versions of the mongodump and mongorestore tools for this procedure. To download the tools, see http://www.mongodb.com/download-center.

Indexes

mongodump captures any configured indexes, but does not dump the indexed data. The destination Paid Tier cluster performs foreground index builds of any configured indexes once the migration procedure completes. You may see lower query performance while the Paid Tier cluster rebuilds any configured indexes.

Procedure

Note

If using a Windows machine to execute this procedure, use mongodump.exe and mongorestore.exe.

You must be logged in to a Atlas account associated to the Free Tier cluster for this procedure. To log into Atlas, go to https://www.cloud.mongodb.com and enter your credentials.

1

Deploy a new Atlas cluster.

If you already have an Atlas Paid Tier cluster as a migration target, skip this step.

  1. Click the Groups dropdown and select the Atlas group.
  2. Click Clusters.
  3. Click Add New Cluster.
  4. Configure your new cluster. Ensure MongoDB Version is set to 3.4.
  5. Click Continue to Payment. Enter your preferred payment method.
  6. Click Confirm & Deploy.

For complete documentation on creating a new cluster, see Create a Cluster.

Continue to the next step once Atlas completes deployment of the new cluster.

2

Add the required IP addresses to the Atlas group whitelist.

  1. Click Clusters.
  2. Click Security.
  3. Click IP Whitelist.
  4. Click Add IP Address.
  5. Enter the IP address or CIDR block corresponding to the machine executing the mongodump and mongorestore programs.

For complete documentation on IP Whitelisting, see Add Entries to the Whitelist

If the Free Tier and Paid Tier clusters are in different Atlas groups, you must perform this step in each group.

3

Create MongoDB Users for backup and restore.

  1. Click Clusters.
  2. Click Security.
  3. Click Users.
  4. Click Add New User.
  5. Create a new user named Migrate and assign it the Atlas Admin role.

For complete documentation on configuring MongoDB users in Atlas, see Add MongoDB Users.

If the Free Tier and Paid Tier clusters are in different Atlas groups, you must perform this step in each group.

4

Copy and execute the following command.

  1. Copy the following command into a text editor:

    mongodump --host <hostSource> --archive --ssl -u <sourceUsername> -p <sourcePassword> --authenticationDatabase admin --oplog | mongorestore --host <hostDestination> --ssl -u <destinationUser> -p <destinationPassword> --authenticationDatabase admin --archive --oplogReplay
    

    This command uses mongodump to create a point-in-time data dump of the Free Tier cluster. It then pipes the output of mongodump to mongorestore, which restores the data onto the target Paid Tier cluster.

  2. Replace the <hostSource> with the host information of the Free Tier cluster. To retrieve the host information, click the Connect button for the Free Tier cluster.

    Specify the host information using the replica set name as the prefix, followed by a forward slash and a comma separated list of each replica set member. For example:

    myAtlasFreeTier/freetier.example.net:27017,freetier2.example.net:27017,freetier3.example.net:27017
    
  3. Replace the <sourceUsername> with the username of the MongoDB user you created in the previous step.

    If the Free Tier and Paid Tier clusters are in different Atlas groups, specify the user you created for the Free Tier group.

  4. Replace the <sourcePassword> with the password of the MongoDB user you created in the previous step.

    If the Free Tier and Paid Tier cluster are in different Atlas groups, specify the password for the Free Tier user.

  5. Replace the <hostDestination> with the host information of the Paid Tier cluster. To retrieve the host information, click the Connect button for the Paid Tier cluster.

    If the Paid Tier cluster is a replica set, specify the host information using the replica set name as the prefix, followed by a forward slash and a comma separated list of each replica set member. For example:

    myAtlasPaidTier/paidtier.example.net:27017,paidtier2.example.net:27017,paidtier3.example.net:27017
    
  6. Replace the <destinationUsername> with the username of the MongoDB user you created in the previous step.

    If the Free Tier and Paid Tier clusters are in different Atlas groups, specify the user you created for the Paid Tier group.

  7. Replace the <destinationPassword> with the password of the MongoDB user you created in the previous step.

    If the Free Tier and Paid Tier cluster are in different Atlas groups, specify the password for the Paid Tier user.

Example

mongodump --host myAtlasFreeTier/freetier.example.net:27017,freetier2.example.net:27017,freetier3.example.net:27017 --archive --ssl -u Migrate -p migratepwd --authenticationDatabase admin --oplog  | mongorestore --host myAtlasPaidTier/paidtier.example.net:27017,paidtier2.example.net:27017,paidtier3.example.net:27017 --ssl -u Migrate -p migratepwd --authenticationDatabase admin --archive --oplogReplay
5

Execute the combined mongodump and mongorestore command.

Important

If possible, stop any writes to the Free Tier cluster before this step. Writes that occur after mongodump completes dumping data are not reflected in the Paid Tier cluster.

At the completion of this step, update your applications to point to the Paid Tier cluster and resume normal read and write operations.

Copy the code created in the previous step from your text editor into a shell and execute it.

When the process completes, the Paid Tier cluster reflects the state of the Free Tier cluster when the mongodump process completed the dump.

6

Remove the MongoDB users created for the migration process.

  1. Click Clusters.
  2. Click Security.
  3. Click Users.
  4. Click Delete for the user you created as part of this procedure.

If the Free Tier and Paid Tier clusters are in different Atlas groups, you must perform this step in each group.