export entire mongodb database code example

Example 1: mongodb export entire database

// EXPORT
mongodump -d  -o 
// IMPORT
mongorestore -d  

Example 2: how to export mongodb database to json

sudo mongoexport --db newdb -c restaurants --out newdbexport.json

Example 3: how to export mongodb database

Mongo Export/dump
mongodump --out  --db  --host  --authenticationDatabase admin --ssl --username  --password
Example:
mongodump --out ~/Desktop/mongoData/ --db newdata --host cluster0-shard-01-02.xyz.mongodb.net:27017  --authenticationDatabase admin --ssl --username abc --password xyz

Mongo Import/restore
mongorestore  --db  --host  --authenticationDatabase admin --ssl --username  --password
Example:
mongorestore ~/Desktop/mongobkup/ --host cluster0-shard-00-02.xyz.mongodb.net:27017  --authenticationDatabase admin --ssl --username abc --password xyz

Tags:

Misc Example