1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

herokuのDBをローカルにリストアしたときのメモ

Last updated at Posted at 2015-01-13

Herokuの本番環境のDB内のデータをローカル環境のデータベースに適応したときのメモです。

①バックアップ用のIDの取得

$ heroku pgbackups:capture --app [AppName]
HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> b040

※app一覧の取得方法

$ heroku list

②バックアップ用のURLの取得

$ heroku pgbackups:url b040 --app [AppName]

"https://s3.amazonaws.com/hkpgbackups/app20000000@heroku.com/b040.dump?>AWSAccessKeyId=AAAAAAAAAAAA&Expires=1396852629&Signature=BBBBBBBBBBBBBBBB%2CCCCC"

③バックアップデータの取得

$ curl -o [latest.dump(保存データ名)] "https://s3.amazonaws.com/hkpgbackups/app20000000@heroku.com/b040.dump?AWSAccessKeyId=AAAAAAAAAAAA&Expires=1396852629&Signature=BBBBBBBBBBBBBBBB%2CCCCC"

③LocalのDBにリストア

$ pg_restore --verbose --clean --no-acl --no-owner -h localhost [ユーザ名] -d [データベース名] [latest.dump(保存データ名)]

※ローカルのデータベースの確認

$ psql -l

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?