Skip to main content
Version: Develop

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.

mongodump --username=<admin_username> --password=<admin_password> \
--authenticationDatabase=admin --db=<deployment-name> --host=<primary-addr>

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.

mongorestore --drop --username=<admin_username> --password=<admin_password> \
--authenticationDatabase=admin --db=<new-deployment-name> --host=<primary-addr> \

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> \


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