Error:
Failed: error writing data for collection XYZ.abc
to disk: error reading collection: Failed to parse: { find: “ProductMmsg”, skip: 0, snapshot: true, $readPreference: { mode: “secondaryPreferred” }, $db: “XYZ” }. Unrecognized field ‘snapshot’.
Reason for error:
This usually happens due to different versions between mongodump or mongoexport vs your MongoDB server. For example, you are exporting or dumping using version 3.6 and your MongoDB server is on version 4.0
Possible solution of this error:
First, the solution is to use the same version as the version of your MongoDB server.
Second, the solution is used –forceTableScan in your command
mongodump --forceTableScan -d database_name -o target_directory
Also Read : Start & Stop Mongo DB Server
mongoexport --forceTableScan -d dbname -o Mongo.json
Starting with MongoDB 4.4, the MongoDB Database Tools are now released separately from the MongoDB Server and use their own versioning, with an initial version of
MongoDB100.0.0
. Previously, these tools were released alongside the MongoDB Server and used matching versioning.
If you are using MongoDB 4.4+ then mongodump, mongoexport, mongorestore
will not available with MongoDB server installation you need to download the mongo tool separately.
Reference: https://docs.mongodb.com/manual/reference/