Created
May 5, 2015 11:03
-
-
Save sdrew/cdccaff5db19ac48cf5a to your computer and use it in GitHub Desktop.
Upgrade PSQL
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
apt-get install postgresql-9.3 pgadmin3 postgresql-contrib-9.3 # contrib is needed for hstore | |
su - postgres | |
psql -p 5432 -c "\l" # check the collation column and note that (for ex. en_US.UTF8) | |
psql -p 5433 -c "\l" # If the collation is the same, continue. If not, recreate the 9.3 cluster with the following commands | |
# Recreate 9.3 cluster with collation from old 9.1 cluster | |
# pg_ctlcluster 9.3 main stop | |
# pg_dropcluster 9.3 main | |
# export LC_ALL="<old-clusters-collation>" # For ex. LC_ALL="en_US.UTF8" | |
# pg_createcluster 9.3 main | |
# Stop all running postgresql servers | |
/etc/init.d/postgresql stop | |
# Must link conf file into data directory since it's expected there by pg_upgrade. | |
# Unfortunately, Ubuntu places it in /etc default (which complicates the upgrade) | |
ln -s /etc/postgresql/9.1/main/postgresql.conf /var/lib/postgresql/9.1/main/postgresql.conf | |
ln -s /etc/postgresql/9.3/main/postgresql.conf /var/lib/postgresql/9.3/main/postgresql.conf | |
# Run the pg_upgrade, but as the postgres user instead of root. | |
su - postgres | |
/usr/lib/postgresql/9.3/bin/pg_upgrade -d /var/lib/postgresql/9.1/main -D /var/lib/postgresql/9.3/main -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -k -v | |
# Hopefully upgrade finished without error! In which case, we can start up PostgreSQL... | |
/etc/init.d/postgresql start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment