Mondump and Mongorestor; field not found

I am trying to dump a database from another server (this works fine) and then restore it to the new server (this does not work fine).

First I run:

mongodump --host -d 

This creates a dump/db folder that contains all the bson documents.

Then in the dump folder, I run:

 mongorestore -d dbname db 

This works and repeats through the files, but I get this error on dbname.system.users

 Wed May 23 02:08:05 { key: { _id: 1 }, ns: "dbname.system.users", name: "_id_" } Error creating index dbname.system.usersassertion: 13111 field not found, expected type 16 

Any ideas how to solve this problem?

+6
source share
4 answers

Is it likely that the source and destination are different versions?

In any case, to get around this, restore the collection individually using the -c flag in the target database, and then create the indexes later. The system collection is the one used for indexes, so it’s quite easy to recreate it - try to make it last as soon as everything else is restored, and if it still fails, you can always simply recreate the corresponding indexes.

+7
source

If these are really different versions, use the --noIndexRestore option. And create an index after that.

+9
source

The problem can also be caused by this error in older versions of Mongo (in my case it was 2.0.8):

https://jira.mongodb.org/browse/SERVER-7181

Basically, you get error 13111 field not found, expected type 16 , when in fact you need to enter authentication information.

And an example of how I fixed it:

 root@precise64 :/# mongorestore /backups/demand/ondemand.05-24-2013T114223/ connected to: 127.0.0.1 [REDACTED] Fri May 24 11:48:15 going into namespace [test.system.indexes] Fri May 24 11:48:15 { key: { _id: 1 }, ns: "test.system.users", name: "_id_" } Error creating index test.system.usersassertion: 13111 field not found, expected type 16 # Error when not giving username and password root@precise64 :/# mongorestore -u fakeuser -p fakepassword /backups/demand/ondemand.05-24-2013T114223/ connected to: 127.0.0.1 [REDACTED] Fri May 24 11:57:11 /backups/demand/ondemand.05-24-2013T114223/test/system.users.bson Fri May 24 11:57:11 going into namespace [test.system.users] 1 objects found # Works fine when giving username and password! :) 

Hope someone who releases will not be fixed by the previous 2 answers!

+3
source

This can also happen if you are trying to run mongorestore in MongoDB 2.6+, and the dump you are trying to restore contains the system.users table in any database other than admin. In MongoDB 2.2 and 2.4, system.users collections can be found in any database. The authentication scheme migration associated with MongoDB 2.6 moved all users to the system.users table in the administrator database, but left the system.users tables in other databases (MongoDB 2.6 simply ignores them). This seems to trigger this statement when importing into MongoDB 2.6.

0
source

Source: https://habr.com/ru/post/916419/


All Articles