Given the following database and related collection scows.tasks, how do I export 2GB it for storage purposes so to make space?
Try one of suggested option (Ubuntu terminal):
#localhost:27017 security disabled
mongoexport --db scows --collection tasks --out /tmp/tasks.json
#some_ip:some_port security disabled
mongoexport --host="some_ip:some_port" --db scows --collection tasks --out /tmp/tasks.json
#some_ip:some_port security enabled
mongoexport --host="some_ip:some_port" --username=user --password=pass --db scows --collection tasks --out /tmp/tasks.json
This will export JSON file (no compression) into /tmp directory
But if you export with mongodump
command, you can compress your exported data
mongodump --host="some_ip:some_port" --username=user --password=pass --db scows --collection tasks --gzip --out /tmp
This will export BSON structured files (compressed) into /tmp/scows directory
EDIT: Export from MongoDB Atlas, use this:
mongoexport --uri="mongodb+srv://username:password@vessel-tracker-cluster-x2lpw.mongodb.net/scows" --collection tasks --out /tmp/tasks.json
2020-02-13T20:20:51.387+0100 connected to: mongodb+srv://[**REDACTED**]@vessel-tracker-cluster-x2lpw.mongodb.net/scows
2020-02-13T20:20:52.522+0100 [........................] scows.tasks 0/XXX (0.0%)
2020-02-13T20:20:52.642+0100 [########################] scows.tasks XXX/XXX (100.0%)
2020-02-13T20:20:52.643+0100 exported XXX records
EDIT 2: User has DNS issue which ignores --uri parameter and connects to localhost. Adding public DNS to resolve.conf, mongoexport was able to export the data