Index creation error during mongorestore

Hi,

I’m encountering an error during a mongorestore. Basically, the restoring phase ends without any errors, but the index creation fails with

createIndex error: (DuplicateKey) Index build failed:  caused by :: E11000 duplicate key error

I do indeed have one duplicate document in the collection, but as far as I know that should trigger

continuing through error: E11000 duplicate key error

during the restoring phase. I can see that message in a couple of the other collections that I’m restoring, and the indexes of those collections are created correctly.

What should I look for to solve this ?
Thanks

One is for the case that a unique index is violated during the document insert stage. This could be an existing index or the mandatory _id index.

The other is for the case of the unique index being recreated after the data import.

Chris is spot on. FYI you can set --noIndexRestore to stop mongorestore building indexes if you need. See: https://www.mongodb.com/docs/database-tools/mongorestore/#std-option-mongorestore.--noIndexRestore