mongoexport
exports data from MongoDB collections to JSON or CSV files
TLDR
Export collection to JSON
$ mongoexport --db=[database] --collection=[collection] --out=[output.json]
Export to CSV$ mongoexport --db=[database] --collection=[collection] --type=csv --fields=[field1,field2] --out=[output.csv]
Export with query filter$ mongoexport --db=[database] --collection=[collection] --query='{"field":"value"}'
Export from remote host$ mongoexport --host=[hostname] --port=[27017] --db=[database] --collection=[collection]
SYNOPSIS
mongoexport [options]
DESCRIPTION
mongoexport exports data from MongoDB collections to JSON or CSV files. Part of MongoDB Database Tools. Useful for backups, data migration, and reporting.
PARAMETERS
--db name
Database name.--collection name
Collection to export.--out file
Output file path.--type type
Output type (json, csv).--fields fields
Fields for CSV export.--query json
Filter query.--host host
MongoDB host.
SEE ALSO
mongoimport(1), mongodump(1)
