I have a mongo-database where existing entries never change but new entries are added every day. I have ~1000 dumps, each is the new data that was added on the corresponding day.

I.e. I have the following files:


I would like to restore "mydatabase" containing all the collections. The content in each of the collections should be appended to the existing collections instead of overwriting them.

When I run

mongorestore /dump1
mongorestore /dump2

will this append my data to the existing collections or overwrite them?


Find below the wordings from MongoDB official documentation

Insert Only

mongorestore can create a new database or add data to an existing database. However, mongorestore performs inserts only and does not perform updates. That is, if restoring documents to an existing database and collection and existing documents have the same value _id field as the to-be-restored documents, mongorestore will not overwrite those documents.

To answer your question, no the documents won't be overwritten.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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