how to download mongodb collection code example
Example 1: mongoexport whole database
mongodump --uri="mongodb://YOUR_USER_ID:YOUR_PASSWORD@YOUR_HOST_IP/YOUR_DB_NAME" --gzip --archive > YOUR_FILE_NAME
Example 2: how to export mongodb database
Mongo Export/dump
mongodump --out </path> --db <dbName> --host <hostname:portNo> --authenticationDatabase admin --ssl --username <Remote Db User> --password<Remote Db 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 </path> --db <dbName> --host <hostname:portNo> --authenticationDatabase admin --ssl --username <Remote Db User> --password<Remote Db Password>
Example:
mongorestore ~/Desktop/mongobkup/ --host cluster0-shard-00-02.xyz.mongodb.net:27017 --authenticationDatabase admin --ssl --username abc --password xyz