T M
T M

Reputation: 95

Heroku: how to transfer database from the existing application to the new one?

I want to create the new application from the existing one using Heroku.

I cloned the old app to the new one and changed old name to the new one on Heroku.

I’ve transferred the environmental variables using as below:

$ heroku config -s -a existing-heroku-app > config.txt
$ cat config.txt | tr '\n' ' ' | xargs heroku config:set -a new-heroku-app

DATABASE_URL for the new application was created automatically when I've cloned the existing application and I could not change it using edit option on Heroku.

How to transfer database from old application to the new one?

Updated:

I tried as below

$ heroku pg:copy old::postgres://cbnedduwickhsw:c30d4bf09f3f0e756e6360b9331e8b001c70b6dc5c2c4cee899e71ad972f3f23@ec2-55-165-254-49.compute-1.amazonaws.com:5432/d9egrorbiba5at postgres://gjducqczpmibkn:0c7e9eecead030222792675a076c8980e8bd6edf2f68ba38465fbe978097445a@ec2-184-76-153-63.compute-1.amazonaws.com:5432/dfa8rqk1n47ec0--app new-staging

But have error

-bash: postgres://gjducqczpmibkn:0c7e9eecead030222792675a076c8980e8bd6edf2f68ba38465fbe978097445a@ec2-184-76-153-63.compute-1.amazonaws.com:5432/dfa8rqk1n47ec0--app: No such file or directory

Upvotes: 0

Views: 460

Answers (1)

mechnicov
mechnicov

Reputation: 15248

From Heroku documentation

You can also transfer directly from a database on another app:

$ heroku pg:copy sushi::ORANGE GREEN --app sushi-staging

This would copy data from the ORANGE database of the sushi app to the GREEN database in sushi-staging. This could be used to copy production data into a staging app for testing purposes.

Usually there just one database per one Heroku app.

So you can run it as

$ heroku pg:copy old-app::DATABASE_URL DATABASE_URL --app new-app

Replace only old-app and new-app with your data.

Upvotes: 1

Related Questions