Copy database to review app


I'd like to copy a staging/production database to my review apps on creation.


Hi there,

Our advice in is:

Copying full database contents from parent to Review apps (similar to heroku fork) is not currently supported. Copying production data to test apps means the risk of data leaks or other programming mistakes operating on recent customer data. For those reasons, we instead recommend seeding databases comprehensively with non-production data using seed scripts run with the postdeploy command.

A couple of workarounds I've used in the past are to attach the staging DB to review apps using heroku addons:attach when there aren't any destructive actions (such as migrations), or copying the latest backup of the staging database to the review app with heroku pg:backups:restore or even curl <review app url> | pg_restore --verbose --clean --no-acl --no-owner --dbname $DATABASE_URL in a postdeploy script.

To enable heroku commands on the dyno you can try this unofficial buildpack

Another option is the release phase which runs after the app is deployed

I do this only when I know that staging is a safe set of data and not a production fork, so that the worries around data leaks are lessened.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support
Terms of Service Privacy Cookies © 2019