23 June,2020 by Rambler
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'.
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
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |