22
21

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 2013-01-11

バックアップを取るまで

バックアップを取れるAdd Onを入れる

heroku addons:add pgbackups

バックアップを取得

heroku pgbackups:capture

ローカルにdumpファイルを保存するまで

バックアップ一覧を見る

heroku pgbackups

バックアップ先のURLを取得

heroku pgbackups:url

リビジョン(heroku pgbackupsで出てくるID)を引数に取ることも可能

heroku pgbackups:url b001

これはdumpファイルのURLなのでwget,curlなどで取得して、pg_restoreで復元できる

一例としては、以下のようにする

curl heroku pgbackups:url | pg_restore --verbose --clean --no-acl -O -h ${host} -U ${user} -d ${database}

参考

22
21
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
22
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?