Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Upgrading PostgreSQL to 13 in Ubuntu 20.04 for Gitlab 16.0

Permalink

Changing the apt repository

By default, Ubuntu 20.04 installs PostgreSQL 12. If you want to upgrade to version 13, you need to use the official PostgreSQL repository.

To change the repository, run the following commands in the terminal:

# Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# Update the package lists:
sudo apt-get update

Installing PostgreSQL 13

sudo apt-get -y install postgresql-13

Checking if PostgreSQL 13 is available

dpkg --get-selections | grep postgres
pg_lsclusters

Stopping and upgrading the database

sudo service postgresql stop
sudo pg_renamecluster 13 main main_pristine
sudo pg_upgradecluster 12 main

Starting the database

sudo service postgresql start
pg_lsclusters

Stopping the old database

sudo pg_dropcluster 12 main --stop
sudo pg_dropcluster 13 main_pristine --stop

It’s also safe to upgrade directly to version 15. For more information, you can refer to the original reference.

Comments