Today I needed to transfer all the data from one application (production environment) to another (staging environment).

I'm pretty aware that the taps gem exists (which is great btw, and I use to pull the data from the production environment to my development environment), but the problem with the taps gem is that a table with a lot of data and some indexes will take a while to migrate.

I guess it was my lucky day because Thoughtbot tweeted with exactly what I needed. Turns out that using the PG Backups addon it's really easy and fast!

heroku addons:add pgbackups --remote staging
heroku addons:add pgbackups --remote production
heroku pgbackups:capture --remote production
heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging

That's all you need! Those 4 lines (actually, the last 2) will backup your production database and then restore that backup in your staging database.

Here is the original gist.