tf-scripts/pgsql_maint202412.sh

29 lines
1009 B
Bash
Raw Normal View History

2024-12-04 16:08:43 +00:00
#!/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.