Skip to content

Importing and Exporting Data

Estimated time to read: 1 minute

Exporting Data

Data in MongoDB is stored in BSON but is viewed in JSON. When exporting data from MongoDB, the intended use of the data should be taken into account to help define to required export format.

For example:

Scenario Export Type
Export to a local machine JSON
Export to a different system BSON
Backup cloud data locally BSON

Export Commands

Data can be exported from the cluster using the following commands, dependant on the required export data type.

BSON

mongodump --uri "<<Atlas Cluster URI>>" exports the data in BSON.

JSON

mongoexport --uri "<<Atlast Cluster URI>> --collection<collectionName> --out=<filename.json" exports the data in JSON.

Importing Data

JSON

monogoimport --uri "<<Atlas Cluster URI>>" -drop=<filename>.json imports data from JSON.

See mongoimport for more information.

BSON

mongorestore --uri "<<Atlas Cluster URI>> --drop dump imports data from BSON.

URI String

A URI with the type srv string is used to connect to an Atlas cluster. For example, mongodb+srv://<user>:<password>@<clusterURI>/<database>

The srv string type is used to establish a secure connection to the cluster.

See Mongo SRV for more information.