Reputation: 11476
I am doing to following to sync mongodb database between two instances as follows but it doesn't seem to work,anyone know what should I do to fix it?
mongodump --uri="mongodb://username1:[email protected]:27017" --db=databaseName --archive="mongodbdump.bson"
mongorestore --username=username2 --password=password2 --authenticationDatabase=databaseName --host=replicaset1:port1,replicaset2:port2,replicaset3:port3 --archive=mongodbdump.bson
Error:
0 document(s) restored successfully. 41419 document(s) failed to restore
Upvotes: 2
Views: 284
Reputation: 1690
You probably have an unique index conflict with the _id, you need to use the --drop option
Before restoring the collections from the dumped backup, drops the collections from the target database. --drop does not drop collections that are not in the backup.
Upvotes: 1