Update Postgres major version using pg_upgrade on Debian
In Postgresql world you need to upgrade your database to a new major version on your own. Postgres provides the pg_upgrade executable to do so:
(I am going to upgrade from 9.3 to 9.4)
Easy way:
pg_dropcluster 9.4 main
pg_upgradecluster 9.3 main
That’s it. There is also an other way descried in the postgresql wiki Harder way:
cd /tmp
sudo -H -u postgres /usr/lib/postgresql/9.4/bin/pg_upgrade \
-b /usr/lib/postgresql/9.3/bin \
-B /usr/lib/postgresql/9.4/bin \
-d /var/lib/postgresql/9.3/main \
-D /var/lib/postgresql/9.4/main \
-o ' -c config_file=/etc/postgresql/9.3/main/postgresql.conf' \
-O ' -c config_file=/etc/postgresql/9.4/main/postgresql.conf'
Lowercase options are for the old database and uppercase options are for the new database.
- -b Binary directory
- -d Data directory
- -o Options