Created
November 13, 2020 13:20
-
-
Save zealot128/ed41fcc4d25b555c45d73abb77051f4b to your computer and use it in GitHub Desktop.
Quick Postgresql (Ubuntu) upgrade script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# hint: Run via ssh: | |
# ssh root@somehost 'bash -s' < upgrade_pg.sh | |
FROM=9.4 | |
TO=9.6 | |
psql --version | |
apt update | |
echo "upgrading pg - downtime starts now!" | |
apt install postgresql-$TO postgresql-client-$TO postgresql-contrib-$TO | |
sleep 3 | |
service postgresql stop | |
set -e | |
pg_renamecluster $TO main main_pristine | |
pg_upgradecluster $FROM main | |
service postgresql start | |
echo "DONE - removing old clusters and main_pristine, pg will be started and downtime end" | |
pg_dropcluster $FROM main --stop | |
pg_dropcluster $TO main_pristine --stop | |
pg_lsclusters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment