To migrate data between MongoDB instances, you can use mongodump
to export your data. Please note that the mongodump
process only captures the documents in the database in its backup data and does not include index data. Similarly, it excludes the content of the local
database in its output. Also, if the {{oplog}} and {{oplogReplay}} flags are not used, any write operations during the dump operation will not be captured. Changes made to the database during the update process can affect the output of the backup. After this, mongorestore
can be used to rebuild and restore your data to the new Atlas cluster.
To use these tools to migrate data between any two clusters, you can use the following command:
mongodump --host <hostSource> --archive --ssl -u <user1> -p <pwd1> --authenticationDatabase <authdb> | mongorestore --host <hostDestination> --ssl -u <user2> -p <pwd2> --authenticationDatabase admin --archive