Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongorestore fails due to invalid BSONSize

I have a script which dumps a mongodb

mongodump --archive=$MONGODB_PATH --host $MONGODB_HOST --port $MONGODB_PORT --username $MONGODB_USER --password $MONGODB_PASS --db $MONGODB_NAME

but when I try to restore it with

mongorestore -d db_name backup/dump

it fails with:

Failed: dump_name: error restoring from backup/dump/dump_name: reading bson input: invalid BSONSize: -2120621459 bytes

I tried --batchSize=100 but it didn't solve the issue for me.

What's going wrong here?

Solution was: mongorestore --archive=backup/dump

like image 332
Marco Avatar asked Mar 22 '17 10:03

Marco


1 Answers

When you dump with --archive flag you must restore with --archive flag as well.

like image 186
Asya Kamsky Avatar answered Sep 24 '22 15:09

Asya Kamsky