2

I want sync my server db with my local db;

  • dump db

    mongodump --db [db name]

  • copy dump folder into my local
  • restore dump on my local

    mongorestore --db [db name] [dump folder path]

I have 4 dbs I can do this successfully for 3 of them but I got

mongorestore error: failure writing file /var/lib/mongodb

when I restore 4th db

There is enough room on the file system. I restarted the server and repeated the process and I don't get this error anymore. However, sometimes I get:

failed: restore error: cohortV5.orders: 
error restoring from dump/cohortV5/orders.bson: insertion error: EOF

and sometimes I get:

Failed: restore error: cohortV5.orders: error creating indexes for cohortV5.orders: 
createIndex error: no reachable servers
0

3 Answers 3

1

Finally after two days, I found the answer, I get this error because of lack of memory. You need to add more memory if you work with big collection.

3
  • How did you add more memory?
    – nils
    Oct 13, 2015 at 12:19
  • What memory? RAM or disk ?
    – expert
    Oct 21, 2015 at 16:27
  • You need to add RAM. I was running mongo on Amazon t2.small instance, I upgrade the instance to t2.large with 8GB RAM
    – Fartash
    Feb 11, 2016 at 3:51
0

Had the same issue. Some collections are too large to be restored and the error message is "reading bson input: unexpected EOF". Sometimes, the error message is insertion error: unexpected EOF

A workaround for this is that restore exclude the collection with issues, and then start restoring the collections with issue.

A PR was made today to add support for collection exclusion now. Hopefully mongo team would merge this and release soon. (https://github.com/mongodb/mongo-tools/issues/48)

If you need the feature right away, try https://github.com/soleo/mongo-tools , and build with branch TOOLS-976 .

0

Just in case any one is still wondering how to get it done without upgrading ram:

Try

--batchSize=10

along with the mongorestore command. This will not load the whole document into the ram rather in batches

more info here https://stackoverflow.com/questions/34142673/mongo3-0-restore-fails-with-error-failed-restore-error-insertion-error-eof

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.