Install PostgreSQL 9.6 from backport using:
# apt-get -t jessie-backports install postgresql-9.6 postgresql-client-9.6To view PostgreSQL cluster:
# pg_lsclustersVer Cluster Port Status Owner Data directory Log file9.4 main 5432 down postgres /var/lib/postgresql/9.4/main /var/log/postgresql/postgresql-9.4-main.log9.6 main 5433 down postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log"There already is a cluster "main" for 9.6 (since this is created by default on package installation). This is done so that a fresh installation works out of the box without the need to create a cluster first, but of course it clashes when you try to upgrade 9.4/main when 9.6/main also exists. The recommended procedure is to remove the 9.6 cluster with pg_dropcluster and then upgrade with pg_upgradecluster."
To remove cluster 9.6 created during installation:
# pg_dropcluster 9.6 main --stopRedirecting stop request to systemctlNow upgrade our cluster 9.4 to 9.6:
# pg_upgradecluster 9.4 mainStopping old cluster...Notice: extra pg_ctl/postgres options given, bypassing systemctl for stop operationDisabling connections to the old cluster during upgrade...Restarting old cluster with restricted connections...Redirecting start request to systemctlCreating new cluster 9.6/main ... config /etc/postgresql/9.6/main data /var/lib/postgresql/9.6/main locale en_US.UTF-8 socket /var/run/postgresql port 5433Disabling connections to the new cluster during upgrade...Redirecting start request to systemctlRoles, databases, schemas, ACLs...Fixing hardcoded library paths for stored procedures...Upgrading database postgres...Analyzing database postgres...Fixing hardcoded library paths for stored procedures...Upgrading database YOUR_DB...Analyzing database YOUR_DB...Fixing hardcoded library paths for stored procedures...Upgrading database template1...Analyzing database template1...Re-enabling connections to the old cluster...Re-enabling connections to the new cluster...Copying old configuration files...Copying old start.conf...Copying old pg_ctl.conf...Stopping target cluster...Redirecting stop request to systemctlStopping old cluster...Redirecting stop request to systemctlDisabling automatic startup of old cluster...Configuring old cluster to use a different port (5433)...Starting target cluster on the original port...Redirecting start request to systemctlSuccess. Please check that the upgraded cluster works. If it does,you can remove the old cluster with pg_dropcluster 9.4 mainAfter upgrade list cluster becomes like this:
# pg_lsclustersVer Cluster Port Status Owner Data directory Log file9.4 main 5433 down postgres /var/lib/postgresql/9.4/main /var/log/postgresql/postgresql-9.4-main.log9.6 main 5432 online postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.logAfter everything work fine, we can drop old cluster i.e. 9.4
# pg_dropcluster 9.4 main# pg_lsclustersVer Cluster Port Status Owner Data directory Log file9.6 main 5432 online postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.logWe can remove and purge postgresql 9.4
# apt-get --purge remove postgresql-9.4 postgresql-client-9.4Reading package lists... DoneBuilding dependency treeReading state information... DoneThe following packages will be REMOVED: postgresql* postgresql-9.4* postgresql-client* postgresql-client-9.4*0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.After this operation, 25.3 MB disk space will be freed.Do you want to continue? [Y/n] y(Reading database ... 97410 files and directories currently installed.)Removing postgresql (9.4+165+deb8u2) ...Removing postgresql-9.4 (9.4.10-0+deb8u1) ...Purging configuration files for postgresql-9.4 (9.4.10-0+deb8u1) ...Removing postgresql-client (9.4+165+deb8u2) ...Removing postgresql-client-9.4 (9.4.10-0+deb8u1) ...Processing triggers for postgresql-common (178~bpo8+1) ...Building PostgreSQL dictionaries from installed myspell/hunspell packages...Removing obsolete dictionary files:References:
- https://backports.debian.org/Instructions/
- https://gist.github.com/dmitrykustov/27c673ec4f7abd716912e4c830910019