Copying Your Production Database to Staging on Heroku
While working on Roundtrip, I decided the best solution as a one man team was to use Heroku to host my application. It’s just one less thing I need to worry about. On Heroku I have a staging environment, where I test changes before releasing to production. In order to do this, I need to copy the production database over to staging, to test on real data. While looking for an easy way to do this, I came across this Thoughbot article, but it’s a little out of date. Here’s how I managed to copy my data from production to staging in one command.
heroku pg:backups restore `heroku pg:backups public-url --app production-app-name` DATABASE --app staging-app-name
You’ll then be asked to confirm you wish to make changes to your staging application, simply confirm and you’re good to go!
Continue reading →