Question: I've started the a MongoDB migration using the Mongodump module, but when executing the command :
mongodump --username="my_un" --password="my_pw"
I receive the following error message.
Failed: error dumping users and roles: error writing data for collection `admin.system.users` to disk: error reading collection: Failed to parse: { find: "system.users", skip: 0, snapshot: true, $readPreference: { mode: "secondaryPreferred" }, $db: "admin" }. Unrecognized field 'snapshot'.
Related Articles
I've executed the same command on other installations with no issues? Is there quick fix for this error message?
Answer: I've seen this error before and can be related to the default usage of _id during scanning collections. The workaround is to use the --forceTableScan switch .
From the MongoDB documentation:
"By default, mongodump uses the _id index when scanning collections with that index is available (e.g. Views do not have any indexes). Specify --forceTableScan to direct mongodump to scan collection data without the use of the _id index"
mongodump --forceTableScan --username="my_un" --password="my_pw"
Adding the --forceTableScan switch will force mongodump to not use the _id index
Read more on mongodump
How to migrate databases with mongodump and mongorestore