-
Notifications
You must be signed in to change notification settings - Fork 14
Postgres database major version upgrade steps
-
Take a full backup of the database by running the below command in the simsdb-repo-host-0 pod terminal:
pgbackrest --stanza=db backup --type=full
-
Check if the backup is successfully taken by running the below command in the simsdb-repo-host-0 pod terminal:
pgbackrest info
-
Upgrade the database:
make pg-upgrade NAME=crunchy NAMESPACE=<< NAMESPACE >>
-
Monitor the postgres upgrade process with:
oc get pgupgrade -n << NAMESPACE >>
oc describe pgupgrade simsdb-pgupgrade-15-to-17 -n << NAMESPACE >>
-
When monitoring the above status and finding that the status is set to "false" and the reason is listed as "PGClusterNotShutdown" with type as "Progressing", run the below command to annotate the cluster:
oc -n << NAMESPACE >> annotate postgrescluster simsdb postgres-operator.crunchydata.com/allow-upgrade="simsdb-pgupgrade-15-to-17"
-
Now shutdown the cluster to allow the upgrade to proceed:
oc patch postgrescluster simsdb -n << NAMESPACE >> --type=merge -p '{"spec":{"shutdown":true}}'
-
Again monitor the postgres upgrade process with:
oc get pgupgrade -n << NAMESPACE >>
oc describe pgupgrade simsdb-pgupgrade-15-to-17 -n << NAMESPACE >>
One should see the below: Reason: PGUpgradeProgressing Status: True Type: Progressing
After waiting for a few minutes, once the upgrade completes, the status would change as below: Reason: PGUpgradeSucceeded Status: True Type: Succeeded
-
Now set the latest postgres version for the Postgres Cluster resource and then restart the cluster:
oc patch postgrescluster simsdb -n << NAMESPACE >> --type=merge -p '{"spec":{"postgresVersion":17, "shutdown":false}}'
-
After running the above command, run the below to check the status of the pods:
oc get pods -n << NAMESPACE >> -w
-
Once all the pods are up and running, check the postgres version:
oc exec -it << postgres cluster pod name >> -n << NAMESPACE >> -- psql -c "SELECT version();"
Steps for the restore:
- In case of any issues with the upgrade:
For the automated restore using the PVCs, run the following command:
make upgrade NAMESPACE=<< NAMESPACE >> RESTORE_ENABLED=true RESTORE_TARGET=<< set restore time here >>
oc annotate -n << NAMESPACE >> postgrescluster simsdb --overwrite postgres-operator.crunchydata.com/pgbackrest-restore=<< set restore time here >>