A
A
Alexander Wolf2016-04-12 18:20:14
MongoDB
Alexander Wolf, 2016-04-12 18:20:14

How to add (merge) the mongo base?

Good day, colleagues! We had an incident - they changed servers and forgot to transfer the www domain to a new IP (I don’t know why there was no CNAME there, I don’t have time to figure it out). It's been 10 days and we've got a handful of users who registered on the old server (they haven't managed to cut it down yet). So we have 2 bases. You need to merge them (namely, merge them so that if _id is already in the database, then the record is not touched. Any options?
PS: it’s hard to do it manually, there are a lot of collections, and it’s not possible to make a selection by time everywhere.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lega, 2016-04-12
@mannaro

mongorestore (by default) doesn't seem to overwrite existing documents

S
Super User, 2016-04-12
@sergeystepanov1988

I would write a script that will read the old database and add it to the new one if there is no record there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question