Skip to content

Instantly share code, notes, and snippets.

@rocLv
Forked from edib/upgrade_pg.sh
Last active December 12, 2018 02:44
Show Gist options
  • Save rocLv/cdf7e37f20008c3e3ddfa3ab2a51c133 to your computer and use it in GitHub Desktop.
Save rocLv/cdf7e37f20008c3e3ddfa3ab2a51c133 to your computer and use it in GitHub Desktop.
Upgrade PostgreSQL 9.3 to 9.6 on Ubuntu 16.04
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository
deb http://apt.postgresql.org/pub/repos/apt/ xenial-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 postgresql-server-dev-9.6 postgresql-contrib-9.6 -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
sudo systemctl stop postgresql
sudo su - postgres -c '/usr/lib/postgresql/9.6/bin/pg_upgrade -b /usr/lib/postgresql/9.3/bin -B /usr/lib/postgresql/9.6/bin \
-d /var/lib/postgresql/9.3/main/ -D /var/lib/postgresql/9.6/main/ \
-O "-c config_file=/etc/postgresql/9.6/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" --link'
sudo apt-get remove postgresql-9.3 -y
sudo sed -i "s:5433:5432:g" /etc/postgresql/9.6/main/postgresql.conf
sudo systemctl enable postgresql@9.6-main.service
sudo systemctl start postgresql@9.6-main.service
@rocLv
Copy link
Author

rocLv commented Mar 21, 2017

Unable to locate package postgresql-9.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment