Skip to content

Instantly share code, notes, and snippets.

@ziyan-junaideen
Last active January 14, 2018 20:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziyan-junaideen/29d72f9292c9b8fdaa333ebea95afd65 to your computer and use it in GitHub Desktop.
Save ziyan-junaideen/29d72f9292c9b8fdaa333ebea95afd65 to your computer and use it in GitHub Desktop.
How to Update PostgreSQL from v9.5 to v9.6 in an Ubuntu 16.04 system

Background

I was starting a new project and wanted to pull a pg backup from heroku to fix a bug.

➜  review_sys git:(bugfix/33-numeric-updats) heroku pg:pull DATABASE_URL xyz_dev --remote production
heroku-cli: Pulling postgresql-vertical-abcdefg ---> xyz_dev
pg_dump: server version: 9.6.1; pg_dump version: 9.5.5
pg_dump: aborting because of server version mismatch
pg_restore: [archiver] input file is too short (read 0, expected 5)

Summary

Given you have postgres 9.5 installed in an Ubuntu 16.04 system, and assuming you have postgres 9.6 installed, this is how you can upgrade your postgres cluster to the new version.

sudo pg_dropcluster 9.6 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main

If you are wondering, no you don't need to do any thing else, like stopping any active apps. But if you are upgrading on a production server, it will be a good idea to switch to a "maintanance mode" with a frindly message, just incase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment