LoginSignup
2
1

More than 5 years have passed since last update.

heroku の postgres データ移行

Posted at

heroku で運用している app1 の DB を、app2 の DB へ移行したい時。

  • 接続情報を調べる
$ heroku config:get DATABASE_URL --app <app1>
postgres://<username>:<password>@ec2-X-X-X-X.compute-1.amazonaws.com:5432/<dbname>
  • dump
$ pg_dump -h ec2-X-X-X-X.compute-1.amazonaws.com -p 5432 -U <username> -d <dbname> -a > <dumpfile>.sql
  • restore
$ heroku pg:psql --app <app2> < <dumpfile>.sql 
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1