Skip to main content
Version: 55.0.0

Migrating Data Between Instances

The intent of this document is to specify how to migrate data from on MongoDB instance to another, regardless of its topology (single or replicated cluster).

For the following steps you can install the MongoDB CLI tool on your local machine or use the binaries shipped with on every MongoDB virtual machine.

The following steps must be executed on the primary, if you are running a cluster. You can discover which node is the primary with db.adminCommand({replSetGetStatus:1}).

Backup Data

First, make a local copy of the data on your database. The database name is the deployment name.

You should prefer to use the admin credentials specified in the instance deployment manifest under properties.mongodb.admin_username and properties.mongodb.admin_password.

# When the Service Instance is SSL, use `--ssl` `--sslCAFile=<your-ca-file-path>`.
mongodump --username=<admin_username> --password=<admin_password> \
--authenticationDatabase=admin --db=<deployment-name> --host=<primary-addr>
note

When creating a dump meant to be restored on an a9s MongoDB 7.0 Service Instance, ensure the use of the SCRAM-SHA-256 authentication mechanism by including the following flag: --authenticationMechanism=SCRAM-SHA-256.

Restore Data

After creating a new service instance according to your needs, you must restore the backup.

Retrieve the admin credentials for the new service instance, and execute the restore command below.

# When the Service Instance is SSL, use `--ssl` `--sslCAFile=<your-ca-file-path>`.
mongorestore --drop --username=<admin_username> --password=<admin_password> \
--authenticationDatabase=admin --db=<new-deployment-name> --host=<primary-addr> \
<dump-path>/<database-to-restore>

You can also specify the BSON file for a collection directly with:

mongorestore --username=<admin_username> --password=<admin_password> \
--authenticationDatabase=admin --db=<new-deployment-name> --host=<primary-addr> \
<dump-path>/<database-to-restore>/<collection-to-restore>.bson
note

When restoring a dump on an a9s MongoDB 7.0 Service Instance, ensure the use of the SCRAM-SHA-256 authentication mechanism by including the following flag: --authenticationMechanism=SCRAM-SHA-256.

Finalization

With data restored, you can delete the old service instance and bind your application or create new service keys.

For more information, please refer to the mongodb documentation here