Forked from patricksamson/Postgresql pg_upgrade on Ubuntu for pgsql 9.3 to 9.4
Last active
November 30, 2015 00:46
-
-
Save stretchkennedy/72f772d6363fc6bc28d9 to your computer and use it in GitHub Desktop.
Postgresql pg_upgrade on Ubuntu Trusty for pgsql 9.3 to 9.4
This file contains hidden or 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
# Add postgresql repo and update apt listing | |
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list > /dev/null | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
sudo apt-get install postgresql-9.4 -y | |
# Stop all running postgresql servers -- needed for migration of 9.3 data to 9.4 (pg_upgrade execution) | |
sudo /etc/init.d/postgresql stop | |
# Run the pg_upgrade, but as the postgres user instead of root. | |
sudo su postgres -c "cd ~postgres; \ | |
/usr/lib/postgresql/9.4/bin/pg_upgrade -d /var/lib/postgresql/9.3/main \ | |
-D /var/lib/postgresql/9.4/main \ | |
-b /usr/lib/postgresql/9.3/bin \ | |
-B /usr/lib/postgresql/9.4/bin \ | |
-o ' -c config_file=/etc/postgresql/9.3/main/postgresql.conf' \ | |
-O ' -c config_file=/etc/postgresql/9.4/main/postgresql.conf'" | |
# Change the port of the new server from 5433 to 5432, swap old server to 5433 | |
sudo vim /etc/postgresql/9.4/main/postgresql.conf | |
sudo vim /etc/postgresql/9.3/main/postgresql.conf | |
# Other changes to the default config go here | |
# Hopefully upgrade finished without error! In which case, we can start up PostgreSQL... | |
sudo /etc/init.d/postgresql start | |
# Analyze cluster | |
sudo su postgres -c "sh /var/lib/postgresql/analyze_new_cluster.sh" | |
# Restart app server here | |
# Remove postgres 9.3 (TEST 9.4 FIRST) | |
sudo apt-get remove postgresql-9.3 -y | |
sudo su postgres -c "sh /var/lib/postgresql/delete_old_cluster.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment