How-To: Upgrade PostgreSQL From 9.3 to 9.4 (In-Place)
To make use of the JSONB features implemented in 9.4, it may be required that you upgrade your existing PgSQL 9.3 cluster to 9.4+. I cover the basics on how to perform an in-place upgrade.
- 1. Add the PostgreSQL repo to apt:
echo "deb http://apt.postgresql.org/pub/repos/apt/ utopic-pgdg main" > /etc/apt/sources.list.d/pgdg.list
- 2. Install the repo’s key:
wget -q -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add
- 3. Update apt sources and install postgresql-9.4:
apt-get update && apt-get install postgresql-9.4 && pg_lsclusters
- 4. You will now have two pgsql clusters, your existing 9.3 one and the new default 9.4 one. We don’t need the 9.4 one, so we can drop it:
pg_dropcluster --stop 9.4 main && pg_lsclusters
- 5. Use pg_upgradecluster to perform an in-place upgrade of your 9.3 cluster:
pg_upgradecluster 9.3 main && pg_lsclusters
- 6. You will be left with a single, upgraded 9.4 cluster.