r/postgresql-server: Add script to upgrade database

The `postgresql-upgrade.sh` script arranges to run `pg_upgrade` after a
major PostgreSQL version update.  It's scheduled by a systemd unit,
_postgresql-upgrade.service_, which runs only after an OS update.
This commit is contained in:
2024-11-16 11:52:14 -06:00
parent 0048a87630
commit 53b39338dd
4 changed files with 92 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
[Unit]
Description=Upgrade PostgreSQL database cluster
Before=postgresql.service
Before=systemd-update-done.service
After=local-fs.target
RequiresMountsFor=/var/lib/pgsql
DefaultDependencies=no
ConditionNeedsUpdate=/var
[Service]
Type=oneshot
User=postgres
ExecStart=+/usr/local/libexec/postgresql-upgrade
Environment=PG_COLOR=always
WorkingDirectory=~
[Install]
RequiredBy=postgresql.service