user2954587
user2954587

Reputation: 4861

Copy production database to staging heroku

How can I pull my production database to my staging server on heroku?

I have two remotes, production and staging.

From the documentation it appears that I want to run heroku pg:copy COBALT GREEN --app sushi but it isn't clear what all the arguments mean. How can I copy my production database to my staging database?

Upvotes: 3

Views: 1242

Answers (2)

i100
i100

Reputation: 4666

Just to add a clarification to the @Yoni Rabinovitch's answer.

I do not have named database so I needed to replace name with DATABASE_URL instead. It is not much intuitive to duplicate DATABASE_URL, is it?

So instead of:

heroku pg:copy your_production_app::HEROKU_POSTGRESQL_WHITE_URL DATABASE_URL -a your_staging_app

I used

heroku pg:copy your_production_app::DATABASE_URL DATABASE_URL -a your_staging_app

Hope this might help somebody.

Upvotes: 0

Yoni Rabinovitch
Yoni Rabinovitch

Reputation: 5261

First use:

heroku pg:info -a your_production_app

to retrieve the name of the environment variable that has the URL of your production db, e.g HEROKU_POSTGRESQL_WHITE_URL.

Then:

heroku pg_info -a your_staging_app

to get the same for your staging app (e.g. DATABASE_URL).

Finally:

heroku pg:copy your_production_app::HEROKU_POSTGRESQL_WHITE_URL DATABASE_URL -a your_staging_app

Upvotes: 7

Related Questions