Forked from martinseener/postgresql_9.1_to_9.3_on_ubuntu_debian
Last active
January 4, 2017 05:47
-
-
Save patricksamson/b09ce3c14307d594bac3 to your computer and use it in GitHub Desktop.
Postgresql pg_upgrade on Ubuntu for pgsql 9.3 to 9.4
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
# Add postgresql repo and update apt listing | |
echo "deb http://apt.postgresql.org/pub/repos/apt/ squeeze-pgdg main" > /etc/apt/sources.list.d/pgdg. | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get upgrade | |
# Stop all running postgresql servers -- needed for migration of 9.3 data to 9.4 (pg_upgrade execution) | |
sudo /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.3/main/postgresql.conf /var/lib/postgresql/9.3/main/postgresql.conf | |
ln -s /etc/postgresql/9.4/main/postgresql.conf /var/lib/postgresql/9.4/main/postgresql.conf | |
# Run the pg_upgrade, but as the postgres user instead of root. | |
su postgres | |
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 -k -v | |
# Hopefully upgrade finished without error! In which case, we can start up PostgreSQL... | |
/etc/init.d/postgresql start | |
# We can now run, but make sure it works first! | |
#sudo sh /var/lib/postgresql/analyze_new_cluster.sh | |
#sudo sh /var/lib/postgresql/delete_old_cluster.sh | |
#sudo apt-get remove postgresql-9.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment