Closed5

Heroku Postgresのバージョンを上げる(2022)

zundazunda

操作内容

フォロワの作成

$ date -u; heroku addons:create heroku-postgresql:standard-0 --follow postgresql-clean-89871 -a zundan-mastodon
Fri Apr 15 08:29:46 PM UTC 2022
Creating heroku-postgresql:standard-0 on ⬢ zundan-mastodon... $50/month
 ▸    Release command executing: config vars set by this add-on will not be
 ▸    available until the command succeeds. Use `heroku releases:output` to view
 ▸    the log.
The database should be available in 3-5 minutes.
Use `heroku pg:wait` to track status.
postgresql-tetrahedral-12223 is being created in the background. The app will restart when complete...
Use heroku addons:info postgresql-tetrahedral-12223 to check creation progress
Use heroku addons:docs heroku-postgresql to view documentation
$ heroku pg:wait -a zundan-mastodon
$ date -u
Fri Apr 15 08:40:25 PM UTC 2022

書き込みの停止

$ heroku maintenance:on -a zundan-mastodon-streaming
$ heroku ps:scale web=0 -a zundan-mastodon-streaming
$ heroku maintenance:on -a zundan-mastodon
$ date -u
Fri Apr 15 08:46:23 PM UTC 2022
$ heroku ps:scale web=0 -a zundan-mastodon

フォロワのバージョンの更新

$ date -u; heroku pg:upgrade postgresql-tetrahedral-12223 -a zundan-mastodon
Fri Apr 15 08:49:51 PM UTC 2022
$ heroku pg:wait -a zundan-mastodon; date -u
Waiting for database postgresql-tetrahedral-12223... rotating credentials after upgrade
Fri Apr 15 08:54:24 PM UTC 2022

フォロワの昇格

$ heroku pg:promote postgresql-tetrahedral-12223 -a zundan-mastodon
$ heroku addons:attach postgresql-tetrahedral-12223 --as DATABASE -a zundan-mastodon-streaming

書き込みの再開

$ heroku ps:scale web=1 -a zundan-mastodon
$ heroku maintenance:off -a zundan-mastodon; date -u
Fri Apr 15 09:05:16 PM UTC 2022
$ heroku ps:scale web=1 -a zundan-mastodon-streaming
$ heroku maintenance:off -a zundan-mastodon-streaming
zundazunda

結果

$ heroku pg:info -a zundan-mastodon
=== HEROKU_POSTGRESQL_PURPLE_URL, DATABASE_URL
Plan:                  Standard 0
Status:                Available
Data Size:             12.2 GB
Tables:                85
PG Version:            13.6
Connections:           18/120
Connection Pooling:    Available
Credentials:           1
Fork/Follow:           Temporarily Unavailable
Rollback:              earliest from 2022-04-15 21:07 
Created:               2022-04-15 20:29 
Region:                us
Data Encryption:       In Use
Continuous Protection: On
Enhanced Certificates: Off
Forked From:           HEROKU_POSTGRESQL_CYAN
Maintenance:           not required
Maintenance window:    Thursdays 19:30 to 23:30 UTC
Add-on:                postgresql-tetrahedral-12223

=== HEROKU_POSTGRESQL_CYAN_URL
Plan:                  Standard 0
Status:                Available
Data Size:             12.2 GB
Tables:                85
PG Version:            10.20, (deprecating)
Connections:           11/120
Connection Pooling:    Available
Credentials:           1
Fork/Follow:           Available
Rollback:              earliest from 2022-04-11 21:14 UTC
Created:               2019-07-28 23:28 
Region:                us
Data Encryption:       In Use
Continuous Protection: On
Enhanced Certificates: Off
Forks:                 HEROKU_POSTGRESQL_PURPLE
Maintenance:           not required
Maintenance window:    Thursdays 19:30 to 23:30 UTC
Warning:               Postgres version 10 is EOL on 2022-11-10. Upgrade Versions.
Add-on:                postgresql-clean-89871

zundazunda

使用済みデータベースのバックアップの作成

$ heroku pg:backups:capture postgresql-clean-89871 -a zundan-mastodon
 ▸    Continuous protection is already enabled for this database. Logical
 ▸    backups of large databases are likely to fail.
 ▸    See
 ▸    https://devcenter.heroku.com/articles/heroku-postgres-data-safety-and-continuous-protection#physical-backups-on-heroku-postgres.
Starting backup of postgresql-clean-89871... done

Use Ctrl-C at any time to stop monitoring progress; the backup will continue running.
Use heroku pg:backups:info to check progress.
Stop a running backup with heroku pg:backups:cancel.

Backing up CYAN to b551... done
$ heroku pg:backups:url b551 -a zundan-mastodon

表示されたURLから家のサーバのアーカイブにバックアップをダウンロードする。

zundazunda

使用済みデータベースの廃棄。いままでありがとう!!

$ heroku addons:destroy postgresql-clean-89871 -a zundan-mastodon
 ▸    WARNING: Destructive Action
 ▸    This command will affect the app zundan-mastodon
 ▸    To proceed, type zundan-mastodon or re-run this command
 ▸    with --confirm zundan-mastodon

> zundan-mastodon
Destroying postgresql-clean-89871 on ⬢ zundan-mastodon... done
このスクラップは2022/04/16にクローズされました