You might want to also review this post
https://sudonix.org/topic/389/mongodb-backup-script
During the restore of a MongoDB based database, you may receive the error message
E11000 duplicate key error collection
This is because by default the mongorestore
command does not drop existing collections before attempting to recover them, which results in the above error message as the collections already exist
As an example, the command of
sudo mongorestore -d sudonixdev /path/to/database/sudonix -u admin -p <password> --authenticationDatabase=admin
Would need to become
sudo mongorestore --drop -d sudonixdev /path/to/database/sudonix -u admin -p <password> --authenticationDatabase=admin
The addition of --drop
allows the collections to be overwritten by the restore.