diff --git a/pgsql_maint202412.sh b/pgsql_maint202412.sh new file mode 100644 index 0000000..9f99197 --- /dev/null +++ b/pgsql_maint202412.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# This script does the following things: +# - Stop mastodon services +# - Stop postgresql service +# - Delete AWS S3 pgbackrest repository +# - Install postgresql-16 +# - Upgrade existing cluster to postgresql-16 +# - Start postgresql + +# Stop relevant services +systemctl stop mastodon-* && systemctl stop postgresql + +# Delete deprecated AWS repository from pgbackrest stanza +sudo -u postgres pgbackrest --stanza=main --log-level-console=info stop && \ +sudo -u postgres pgbackrest --stanza=main --repo=1 --log-level-console=info stanza-delete + +# Install Postgres 16 and make sure postgresql is stopped again +apt install -y postgresql-16 && systemctl stop postgresql + +# Upgrade pgsql14 cluster to 16 +pg_renamecluster 16 main main_pristine && pg_upgradecluster --method=link 14 main + +# Start postgresql +systemctl start postgresql + +# REMAINING TODO ITEMS +# - Upgrade stanza in pgbackrest - https://pgbackrest.org/user-guide.html#upgrade-stanza +# systemctl start mastodon-* and verify it is working. \ No newline at end of file