Database restoration


#1

Hey all,

I’ve managed to get nearly everything up and running in my local dev environment but whenever I perform mongorestore to get the local version running it hits an error creating index coco.levels: “Index with name: version index already exists with different options”. I tried deleting all local database data and attempting again but that didn’t help. Any help would be greatly appreciated.

Thanks in advance.


#2

I just faced this issue. Stopping the mongo server and removing ./combatcode/coco/mongo/ then doing the mongorestore is what fixed it for me.

I think this bug occurs if you visit localhost:3000 before loading in the db dump.


#3

Ah I don’t actually have coco/mongo at all. What are the files in there? I did access localhost:3000 first though so could be.


#4

I did an ls before I removed it (from ./codecombat/coco)

ls mongo/
coco.0		coco.1		coco.2		coco.ns		journal		local.0		local.ns	mongod.lock

#5

Thanks but those are the ones I removed previously (stored under cocodb/ since I’m on windows). Maybe it’s related to this warning I see further up?

WARNING: collection coco.levels exists with different options than are in the metadata.json file and not using --drop. Options in the metadata file will be ignored.

I’ll keep playing and see if I can find something that works for me.


#6

I’m no expert on the windows setup, but it does sound like it might be related to the database having been created before the import. When you removed the files, was Mongo still running? Perhaps dropDatabase would work better. What version of MongoDB do you have installed?


#7

Mongo was off while I deleted the files (I went back to try it while it was on just in case but it locks the files while its running). I tried it with dropDatabase but unfortunately I still get the same error. It’s version 2.6 that was downloaded via the automated windows installer, should I be using an older version?


#8

2.6 is the correct version. Try using mongorestore with the --drop option.


#9

That worked! Thank you, I feel silly now xD


#10

Oh good! I’ve updated the wiki to recommend using the --drop flag whenever running mongorestore so that others don’t run into the same problem.