mongorestore "E11000 duplicate key error collection"
-
During the restore of a MongoDB based database, you may receive the error message
E11000 duplicate key error collectionThis is because by default the
mongorestorecommand does not drop existing collections before attempting to recover them, which results in the above error message as the collections already existAs an example, the command of
sudo mongorestore -d sudonixdev /path/to/database/sudonix -u admin -p <password> --authenticationDatabase=adminWould need to become
sudo mongorestore --drop -d sudonixdev /path/to/database/sudonix -u admin -p <password> --authenticationDatabase=adminThe addition of
--dropallows the collections to be overwritten by the restore. -
undefined phenomlab has marked this topic as solved on
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login
