سؤال

Most of my heroku apps use one of the addons providing hosted MongoDB (i.e. MongoLab or MongoHQ). A common task for me is to dump the remote data and load it into a local instance for development/debugging. Another task is to open a console logged in to a remote instance.

Is there a convenient way to derive the connection parameters to the remote instances and perform common tasks.

هل كانت مفيدة؟

المحلول

I've written a CLI plugin for working with MongoDB storage:

Install it by running:

$ heroku plugins:install https://github.com/Empeeric/heroku-mongo.git

Then you can get a db-dump of the current data:

$ heroku mongo:dump

and later restore that data.

$ heroku mongo:restore

(One caveat is the copy of system.* collections. Watch out for these)

You can also simply heroku mongo to open a console to the current DB associated with you app (specified by MONGOLAB_URI or MONGOHQ_URL)

Hit heroku mongo --help for the other commands.

Edit:

I'm added two aliases for the dump and restore commands. Also added a flag to automaticly load dumped data into a local DB:

$ heroku dump -l

this will dump the DB used by the app (inferred from heroku config) and load it to a local instance into a DB named the same as the app.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top