Created
November 24, 2020 17:38
-
-
Save bitsnaps/1e397cf9c2e6c2dbf6eb796c429955c3 to your computer and use it in GitHub Desktop.
Upgrade PostgreSQL cluster from 9.5 to 9.6
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
# This script allows to upgrade postgres database server (e.g. 9.5 to 9.6) | |
# References: | |
#https://gorails.com/guides/upgrading-postgresql-version-on-ubuntu-server | |
#https://stackoverflow.com/questions/13733719/postgresql-which-version-of-postgresql-am-i-running/54514786#54514786 | |
#https://stackoverflow.com/questions/46687645/upgrade-postgresql-from-9-6-to-10-0-on-ubuntu-16-10 | |
#https://stackoverflow.com/questions/47029055/how-do-i-upgrade-my-postgresql-9-5-to-postgresql-10-on-ubuntu-16-04 | |
#https://askubuntu.com/questions/831292/how-do-i-install-postgresql-9-6-on-any-ubuntu-version | |
#https://chartio.com/resources/tutorials/how-to-view-which-postgres-version-is-running/ | |
# Detect current PostgreSQL version | |
#postgres -V | |
#psql -V # client version | |
#psql postgres -c "SELECT version();" | |
# Upgrade repo | |
sudo apt-get upgrade | |
# Set default postgres database password | |
#sudo passwd postgres | |
# Find currently installed versions | |
#dpkg --get-selections | grep postgres | |
# List all clusters | |
#pg_lsclusters | |
# Stop the service | |
sudo service postgresql stop | |
# Install PostgreSQL the new version | |
# Ubuntu 17.04 - 17.10 (use `lsb_release -a` to detect ubuntu version): | |
#sudo apt-get install postgresql-9.6 | |
# Ubuntu 14.04, 16.04 : | |
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get install postgresql-9.6 | |
# Rename the new Postgres version's default cluster (in case of cluster name conflict) | |
#sudo pg_renamecluster 9.6 main main_pristine | |
# Upgrade the old cluster to the latest version | |
sudo pg_upgradecluster 9.5 main | |
# Make sure everything is working again | |
sudo service postgresql start | |
# List all clusters | |
#pg_lsclusters | |
# Drop the old unused cluster (DATABASES IN THIS CLUSTER WILL BE DELETED!!!) | |
#sudo pg_dropcluster 9.5 main | |
# You may need to restore the default PORT number | |
#https://www.jamescoyle.net/how-to/3019-how-to-change-the-listening-port-for-postgresql-database |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment