How to dump and restore in MongoDB
1. Dump
Local database
mongodump --db=test-db
Remote database
mongodump -u=USERNAME -p=PASSWORD --host=HOST_NAME/HOST_IP --port=HOST_PORT --out {YOUR_DIRECTOTY_PATH} --db=DB_NAME
After dumping you will have a dump directory
➜ ~ tree dump
dump
└── test
├── cats.bson
├── cats.metadata.json
├── device.bson
├── device.metadata.json
├── event_data.bson
├── event_data.metadata.json
├── organisation.bson
├── organisation.metadata.json
├── organization.bson
└── organization.metadata.json
2. Restore
This will restore everything to your local mongo instance
mongorestore dump/
If you want to dump a specific collection, you can filter like below while restoring
mongorestore --nsInclude=test.cats dump/