Overview
To restart a migration, you must first stop the ongoing mongosync process.
During the migration process, mongosync creates databases with
your data ("user databases") and the mongosync_reserved_for_internal_use
system database on the destination cluster. You must remove those databases
before restarting mongosync.
Steps
Follow these steps to restart your mongosync migration.
Stop the current mongosync process
Stop the ongoing mongosync process. You can do this by using
Ctrl-C or by calling the /pause endpoint.
Use mongosh to connect to the destination cluster
Connect to the destination cluster with mongosh. If
the destination is a sharded cluster, connect to the
mongos instance. If the destination is a replica set,
connect to the primary mongod instance.
If you already have mongosh installed, run the following
command to connect to your cluster:
mongosh "mongodb+srv://<my-connection-string>"
Disable write-blocking on your destination cluster
Use the mongosh setUserWriteBlockMode database
command to disable write-blocking on your destination cluster:
db.adminCommand( { setUserWriteBlockMode: 1, global: false } )
Remove any user databases created by mongosync on the destination cluster
Remove any user databases created on the destination cluster
by mongosync during the previous migration.
Use
mongoshto list all databases on the destination cluster:show dbs Remove user databases. The
admin,local, andconfigdatabases are system databases. Do not edit these system databases without instructions from MongoDB support.If the
show databasescommand lists any user databases on the destination cluster, you must remove them.Repeat this step for each user database listed by
show databases:use <user database name> db.dropDatabase() Run
show databasesagain to ensure that all databases have been successfully dropped.
(Optional) Enable the balancer on the source and destination clusters
If you want to completely stop the migration, you can re-enable the
balancer on the source and destination clusters by running the
balancerStart command in mongosh on each cluster.
The preceding instructions used mongosh to connect to the destination
cluster. To enable the balancer on your source cluster, use mongosh to connect
to your source cluster and run the following command:
db.adminCommand( { balancerStart: 1 } )
Restart mongosync
Run
mongosyncto reconnect to the source and destination clusters.Use the /start API end point to start syncing.