How can I synchronize a production meteor js database with development?

不想你离开。 提交于 2019-12-21 20:36:38

问题


I'm just getting into Meteor, and am similarly new to MongoDB. I am accustomed to syncing MySQL dbs (production vs dev) for running tests of new features with near-live data. At present, I don't know how to do this with meteor.

From this (http://docs.meteor.com/#meteormongo) I gather that I can use a mongoDB shell to work with my local db, but from looking at http://docs.mongodb.org/manual/mongo/, I haven't yet figured out if this is the path I should be following to sync things up for Meteor.

Has anyone set up a relatively straightforward procedure for syncing Meteor JS db's, or can you point me to resources that might help me get up to speed?


回答1:


Not sure I understood the question, but:

  1. You can choose the db you are working with by setting the MONGO_URL environment variable
  2. You can dump the data from one db and load it to another (if this is what you want to do)



回答2:


There are a couple of interesting ways to do this.

The first method that I have thought about using was by using replicas.

You would have a development server database; by this I mean an entire server dedicated to housing a development database (say a cloud instance on AWS). Once you wish to replace that development instance you would simply take one member out of your live set and start it up as a stand-alone instance replacing your development instance.

Anohter method is to just copy the mongod directory to somewhere and start up a mongod. The simplest method but maybe not the best, especially if you have a large distributed database.

Another method is to use mongodump to dump the data out of the database and the restore it onto your development machine.

The last two are very common methods, the first one is kind of one I have been thinking about in my head for a while.




回答3:


I wrote a quick script for downloading a Production Meteor DB. meteor-download. Easy as ./download.sh origin.meteor.com

It doesn't provide 2-way sync yet, but that shouldn't be too much of a chance if you feel up to it.




回答4:


Check out mongo-sync


It's a script I wrote for my self when I had to constantly copy my Local MongoDB database to and from my Production DB for a Project (I know it's stupid).

Once you put your DB details in config.yml, you can start syncing using two simple commands:

./mongo-sync push       # Push DB to Remote
./mongo-sync pull       # Pull DB to Local

If you use it inside some project, it's a good idea to add config.yml to .gitignore




来源:https://stackoverflow.com/questions/16171613/how-can-i-synchronize-a-production-meteor-js-database-with-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!