Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restoring a dump with mongodb fails

Tags:

mongodb

I've dumped a mongodb database with the following mongodump command line

mongodump -h www.myhost.com -u myusername -p mypassword -d mydb > dump.bson

And I'm trying to restore the dump on my local server:

mongorestore -h localhost -d mydb dump.bson  

Unfortunately it fails with the following error:

assertion: 10264 invalid object size: 1096040772 

Does anyone know what could cause this error?
On both servers mongo's version is 1.8.3

Thanks

like image 848
pierroz Avatar asked Oct 24 '11 08:10

pierroz


2 Answers

Because first string output from mongodump is "db level locking enabled: 0"

You need to do this

tail -n+2 dump.bson > dump_fix.bson
mongorestore -h localhost -d mydb dump_fix.bson
like image 156
azat Avatar answered Oct 23 '22 09:10

azat


excuse my english :P this happened to me when i did export with mongoexport and try to import with mongorestore :D my mistake! i had to use mongoimport. Remember: mongoexport/mongoimport, and mongodump/mongorestore

i hope this is usefull to some one :P

like image 37
mzalazar Avatar answered Oct 23 '22 11:10

mzalazar