Chet
Chet

Reputation: 19829

How to persist mongodb when deploying with meteor?

When I meteor deploy my app, it seems to create an entirely new mongodb instance. I'd like to be able to deploy with the current mongodb have locally.

Same goes the other way -- I'd like to be able to download the mongodb back to my localhost after it has been deployed.

For clarification, I'd really like to know the follow:

1) how to deploy with a fresh mongodb
2) how to deploy to an existing deployed app without overwriting the old mongodb
3) how to download/sync mongodb locally with the existing deployed app
4) how to make local backups of mongodb

Upvotes: 3

Views: 755

Answers (2)

AJ Acevedo
AJ Acevedo

Reputation: 1268

You can perform a mongo dump using meteor mongo to export your local database and deploy your app using Meteor Up which should also allow you to automate the database import and deployment process.

"Meteor Up (mup for short) is a command line tool that allows you to deploy any meteor app into your own server."

Upvotes: 1

Danail Gabenski
Danail Gabenski

Reputation: 3620

You can stop the mongodb service and start a mongod instance in a separate terminal, by just typing mongod. This will let you monitor what's happening on the mongodb instance that you just started.

Open another terminal and do export MONGO_URL=mongodb://localhost:27017/nameOfDBgoesHere This will create a new DB named "nameOfDBgoesHere" and it won't overwrite what you currently have, unless you name it with the same name.

After that just start meteor by typing meteor in your program's folder. In the mongod terminal that you opened you should see some connections opening.

By default mongodb creates it's DB files in /data/db. If you have another meteor app and follow the same steps in another terminal, while keeping the name of the DB you specified in the MONGO_URL you will just connect to it from that app - without overwriting anything.

As for the syncing with a deployed app and the local backups of mongo - it seems like something that the mongodb website covers, but maybe someone can chime in here. Not sure if there is a meteor specific, easy way of doing this.

Upvotes: 0

Related Questions