Migrate from MongoDB® to SingleStore

To migrate your collection from MongoDB® to SingleStore, you can perform the following tasks:

  • Replicate your MongoDB® collections using Change Data Capture (CDC).

  • Back up your collections using mongodump, and then restore the backup into your SingleStore Helios workspace using mongorestore.

  • Export your collection using mongoexport, and then import the exported data into your SingleStore Helios workspace using mongoimport.

Replicate MongoDB® Collections to SingleStore

SingleStore allows you to perform a one-time data replication or ongoing CDC (Change Data Capture) from MongoDB® collections into SingleStore. Refer to Replicate MongoDB® Collections to SingleStore for more information.

Use mongodump and mongorestore

Back Up Data using mongodump

You can back up your collections in the BSON format using the mongodump command-line tool. Run the mongodump command from the system command-line. Refer to mongodump for more information.

Here's a sample command to create a backup:

mongodump --uri="mongodb://<username>:<password>@<MongoDB_endpoint>:27017" \
--db=<database_name> --collection=<collection_name> \
--out=<path_to_output_directory>

For MongoDB® Atlas instances, use the mongodb+srv:// scheme. For example:

mongodump --uri="mongodb+srv://<username>:<password>@<MongoDB_Atlas_endpoint>" \
--db=<database_name> --collection=<collection_name> \
--out=<path_to_output_directory>

Restore the Backup using mongorestore

To restore the backup of your MongoDB® collections created using mongodump into your SingleStore Helios workspace, use the mongorestore command-line tool. Run the mongorestore command from the system command-line. Refer to mongorestore for more information.

Note

Do not restore and build the indexes specified in the backup. Use the --noIndexRestore option to ignore the indexes in the backup. To create indexes in SingleStore, use the CREATE INDEX command instead.

Here's a sample command to restore your MongoDB® backup into SingleStore:

mongorestore \
--uri 'mongodb://<user>:<password>@<SingleStore_Kai_endpoint>:27017/<target_database>?authMechanism=PLAIN&tls=true&loadBalanced=true' \
--noIndexRestore --ssl <path_to_backup>

Use mongoexport and mongoimport

Export Data using mongoexport

You can export your collection in either JSON or CSV format using the mongoexport command-line tool. Run the mongoexport command from the system command-line. Refer to mongoexport for more information.

Run the following command to export collections from a MongoDB® endpoint:

mongoexport --uri='mongodb://<user>:<password>@<MongoDB_endpoint>:27017' \
--db=<database_name> --collection=<collection_name> \
--out=<path_to_output/filename.[json|csv]>

Run the following command to export collections from a MongoDB® Atlas endpoint:

mongoexport --uri mongodb+srv://<username>@<atlas_endpoint>/<database_name> \
--collection=<collection_name> --out=<path_to_output/filename.[json|csv]>

Import Data using mongoimport

To import the data exported using mongoexport into your SingleStore Helios workspace, use the mongoimport command-line tool. mongoimport supports Extended JSON, CSV, and TSV formats that have been exported via mongoexport. Run the mongoimport command from the system command-line. Refer to mongoimport for more information.

mongoimport \
--uri 'mongodb://<user>:<password>@<SingleStore_Kai_endpoint>:27017/?authMechanism=PLAIN&tls=true&loadBalanced=true' \
--db <database_name> --collection <collection_name> \
--file <path_to_import_file/filename.[json|csv]>

If your file contains arrays, add --jsonArray after the database name.

Last modified: March 13, 2024

Was this article helpful?