We have a dev server that contains a collection of objects. The actual accumulation of these objects is a continuous process, on which the entire process of marking, verification, etc. is carried out. On this local dev server. As soon as these objects are ready for production, they are added to the production database, which from now on will use them in their calculations.
I am looking for a way to simply add delta (new objects) to the production database, keeping all other collections and old objects in the same collection that is. So far, we have used MySql, so this process simply involved executing the database structure and data synchronization (we used Navicat for this). Now we move on to MongoDB, so this process is a bit more complicated.
I studied this, and I think the following solutions do not fit my needs:
- Dumping Dev DB and loading it into the production database using mongodump, then mongorestore
- Running db.copyDatabase - Actually replaces the production db with a copy of Dev DB.
Both solutions are problematic because they actually replace the production database when all I want to do is update objects in an existing collection. In addition, the Dev => Production transition does not match the Master-Slave topology.
The best I could come up with was:
- Copy the dev database to the "dev" database on the instance.
- Copy the collection from this dev-DB into the actual production database and add the predicate that I will add only to objects that are similar to this solution that do not exist in the production database.
I was wondering if anyone has a better solution?
If not, does anyone have a script that could execute this?
source share