We have a dev server which contains a collection of Objects. The actual accumulation of these objects is an ongoing process, which runs a whole process of labelling, verification, etc. on this local dev server. Once these objects are production ready, they are added to the Production DB, which will from that moment, use them in its calculations.
I'm looking for a way to simply add the delta (new objects) into the production DB, while retaining all the other collections, and older objects in the same collection as is. Until now, we've used MySql, so this process simply involved running DB structure and data synchronization (we used Navicat for that). We're now moving to MongoDB, so this process is a bit more tricky.
I've looked into this, and I think the following solutions do not fit my needs:
- Dumping the dev DB and loading it in the Production DB using
mongodump
thenmongorestore
- Running
db.copyDatabase
- actually replaces the production db with a copy of the dev DB.
Both solutions are problematic, because they actually replace the Production DB, when all I want to do is update objects in an existing collection. Also, going Dev => Production does not fit the Master-Slave topology.
The best thing I could think of is to:
- Copy the dev DB into a "dev" DB on the production instance.
- Copy the collection from this dev DB to the actual production DB, and add a predicate that I will only add objects that are non-existent in the production DB, similar to this solution.
I was wondering if anyone has a better solution?
If not, does anyone have a script that could perform this?