Step 1: Setup Postgres locally and get working with your app.

Heroku db:pull only works if you have postgres setup locally on your machine.

Go here for some tips on how to do that.

Step 2: Find out your postgres database name.

Before you can run the db:pull command, you need to know what postgres calls your prod database.

Get the name of your app
$ heroku apps

Then get the name of your postgres instance
$ heroku addons –app yourappname | grep POSTGRES
heroku-postgresql:dev HEROKU_POSTGRESQL_ORANGE

Step 3: Export db from prod.

You are now ready to pull the db from prod. Note this is going to create a new local database (to ensure you don’t accidentally blow over anything).

$ heroku pg:pull HEROKU_POSTGRESQL_ORANGE –app

Step 4: Import locally.

Now you just need to point your local database.yaml file to the newly generated postgres instance just created.

development:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: <newdatabase>
  pool: 5
  username: jrasmusson
  password:

Step 5: Voila! You are done.

Restart your web server, fire up your app, and you should now see prod data locally running on your box.

Have fun!

Links that help:

https://devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull

About these ads