How to import heroku postgres locally from prod rails

The Agile Warrior

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.

Step 5: Voila!…

View original post 29 more words