What is difference between mongodump and mongoexport?
mongodump
generates binary copies of data; it creates better, more efficient backups.
mongoexport
can create JSON files; these can be used by other programs, and are basically human-readable as is.
As per MongoDB BOL Here
mongodump is a utility for creating a binary export of the contents of a database. mongodump
can export data from either mongod
or mongos
instances.
mongodump
only captures the documents in the database.The resulting backup is space efficient.
By default, mongodump
does not capture the contents of the local database
.
Changed in version 3.4
: MongoDB 3.4 added support for read-only views. By default, mongodump
only captures a view’s metadata
: it does not create a binary export of the documents included in the view. To capture the documents in a view use --viewsAsCollections
.
Where as MongoDB document Here mongoexport is a utility that produces a JSON or CSV export of data stored in a MongoDB instance.
Run mongoexport from the system command line, not the mongo
shell.
mongoexport Required Access
mongoexport
requires read access on the target database.Ensure that the connecting user possesses, at a minimum, the read role on the target database.
When connecting to a
mongod
ormongos
that enforces Authentication, ensure you use the required security parameters based on theconfigured authentication mechanism
.
Warning: Avoid using mongoimport and mongoexport for full instance production backups. They do not reliably preserve all rich BSON data types, because JSON can only represent a subset of the types supported by BSON. Use mongodump and mongorestore as in MongoDB Backup Methods for this kind of functionality.