mongodump vs mongoexport: which is better?

Viewed 8671

I want to export very large collections and import them into another database in another server. I found there are at least two ways: mongoexport and mongodump.

I searched previous posts about this issue, however I did not find a complete comparison/benchmark about the speed of exporting and size of export file using these two ways! I will be so thankful if there is any experience to share.

3 Answers

As mentioned in the latest documentation

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 described in MongoDB Backup Methods for this kind of functionality.

As you need to restore large data, prefer dump.

mongoexport is a command-line tool that produces a JSON or CSV export of data stored in a MongoDB instance.

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; i.e. can export data from standalone, replica set, and sharded cluster deployments.

One of the important differences is that mongodump is faster than mongoexport for backup purposes. Mongodump store data as a binary, whereas, mongoexport store data as a JSON or CSV.

The best answer to this question here is to use file system snapshots as for large clusters both mongoexport and mongodump can take some significant time.

Related