質問

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?

役に立ちましたか?

解決

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)

他のヒント

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.

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.

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


mongo-sync demo gif

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top