Which one is the preferred Mongodump VS Mongoexport option for updating mongoDB database?

My client is using mongoDB 2.4 and since this version has some limitations, we give them the opportunity to update to the latest stable version of mongoDB 3.4.5.

Initial checking using mongodump in MongoDB 2.4 and mongorestore in Mongodb 3.4.5 worked fine as I can see all imported collections.

From the mongorestore documentation , nowhere is it mentioned that it can restore dumps of older versions of mongoDB.

Since we cannot use mongorestore, can I use mongoexport "to export csv / json data of old mongoDB 2.4 and import to newer mongoDB 3.4?

What are the possible problems of using "mongoexport / mongoimport" instead of "mongodump" to upgrade to a newer version of mongoDB 3.4?

NOTE. I will completely uninstall the old version of mongoDB and install the newer version of mongoDB

+3


source to share


3 answers


Mongodump and Mongorestore are better because:

  • They work faster
  • They preserve some data formats better than mongoexport and mongoimport, as no data is passed from BSON to JSON and vice versa.

As described in the MongoDB Docs on MongoImport :



WARNING
Avoid using mongoimport and mongoexport for full backups of instance instances. They do not reliably store all BSON rich datatypes 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.

Also, be very careful when updating with mongorestore; just because the data is being restored as it was before, it doesn't mean that the new version of MongoDB can work with it. For example, there was a sequence of changes to the authorization model after version 2.2, which means that you must first upgrade to version 2.6, and only then to version 3.0 . Similar structural changes occur in every major release, so it is recommended that you upgrade in stages, one major release at a time .

  • v2.4 → v2.6
  • v2.6 -> v3.0
  • v3.0 -> v3.2
  • v3.2 → v3.4
+6


source


From http://www.dba86.com/docs/mongo/2.4/core/import-export.html , mongoexport has been supported since 2.4. Hence, it must be the right tool for this. But the document also has a warning message.

Warning: Avoid using mongoimport and mongoexport for full backups of instance instances. They do not reliably store all BSON rich data because JSON can only represent a subset of the BSON supported types. Use mongodump and mongorestore as described in Backup MongoDB Methods for this kind of functionality.



Hope that helps !!!!

0


source


Both tools (by default) will simply traverse the _id index to retrieve the data and then write it to disk. So yes, both tools will have the same effect on your working set, so I usually recommend using them against a secondary (preferably a hidden secondary if possible). I assume you are looking for the mongodump equivalent of the --fields option from mongoexport to dump only certain fields. The query option can be used to filter the results, but cannot be used with a projection (to select which fields to return) - this is a feature request that is being tracked in TOOLS-28 but not yet scheduled.

-4


source







All Articles