Copy production data to staging

In this document we are assuming that the name of the application is wheel. The name of staging instance is wheel-staging and the name of production instance is wheel-production.

Find database url for each of the applications

Here is output of executing heroku config -a wheel-production.

DATABASE_URL:               postgres://


Notice that in the above case we see both DATABASE_URL and HEROKU_POSTGRESQL_ROSE_URL. Also notice that both of them have the same value. Names like DATABASE_URL or HEROKU_POSTGRESQL_ROSE_URL are just keys to the actual value. Some applications have names like HEROKU_POSTGRESQL_COBALT_URL.

In this example we will assume that production instance has ROSE name and the staging instance has COBALT name. Before executing the actual command please make the change in name as per the values in your application.

Copy production data to staging

Following code will copy data from production instance to staging instance. Don’t worry before the data is destroyed heroku will prompt you for confirmation.

heroku pg:copy wheel-production::HEROKU_POSTGRESQL_ROSE_URL HEROKU_POSTGRESQL_COBALT_URL -a wheel-staging