Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade to PostgreSQL 11 for Ubuntu 18.04?

As the title suggests I want to upgrade my postgresql-10 to postgresql-11.

I'm using ubuntu-18.04.

like image 976
nicolom Avatar asked Oct 11 '18 17:10

nicolom


2 Answers

Upgrading Postgres to the latest version (currently 13), or to an intermediate version such as 11, should be done by running:

sudo apt install postgresql-common
sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

This is documented on https://wiki.postgresql.org/wiki/Apt
This runs a bash script on your computer. See there if you wish to run the steps manually.

Once you have installed Postgres, the easiest way to upgrade on Ubuntu is with pg_upgradecluster.

  1. Backup your data. You will dropping the database, so no games!
sudo -u postgres pg_dumpall > all.sql
  1. Upgrade.
// Install latest Postgres. Use `postgresql-11` for v11 instead of `postgresql` for latest.   
sudo apt-get install -y postgresql
    
// The install sets up a cluster, which needs then to be removed for the upgrade. 
// Stop and remove the newly installed cluster. Use `11` instead of `13` for v11
sudo pg_dropcluster 13 main --stop
    
// Upgrade the db. Takes the OLD version and OLD schema as required arguments
sudo pg_upgradecluster 10 main
    
// Test. Once you are satisfied, remove OLD cluster.
sudo pg_dropcluster 10 main
like image 110
SamGoody Avatar answered Nov 19 '22 13:11

SamGoody


You can follow this blog setup Postgresql-11 on Ubuntu. I found it easy and simple.

Add the PostgreSQL package repository on your Ubuntu machine

echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main 11" | sudo tee /etc/apt/sources.list.d/pgsql.list

Add the GPG key of the PostgreSQL package repository:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Update APT and install postgresql-11

sudo apt update && sudo apt install postgresql-11
like image 25
Ravindra Singh Ratnawat Avatar answered Nov 19 '22 14:11

Ravindra Singh Ratnawat