Copying Databases on Heroku

This one is going to be an evolving post, as there are many aspects to this process.

Tags: Heroku, databases, postgres, Rails

Back to Blogs

I'll pirate the Heroku docs later on how to set up the staging server, but the part that really threw me for a loop was getting a copy of my database on my staging server. This took many hours on StackOverflow before I finally messaged Heroku support for a ridiculously simple sounding answer.

heroku pg:copy app-being-copied::DATABASE DATABASE --app app-being-copied-to

Seriously. The word DATABASE. Not the complex database url, not any one of the fancy things I'd tried. Not the color of the database. The darn word DATABASE. Argh. There are hours of my life I'll never get back.

If you want to copy a production database to localhost, use pg:pull:

heroku pg:pull DATABASE local-db-name -a app-name

Yes, again, just the word "DATABASE". If you run rake db:drop right before, it will display your local database name, which should be something like ABC_development.

Back to Blogs