#!/bin/bash NEW_PG_VERSION=17 CURRENT_PG_VERSION=14 sudo apt install -y postgresql-common sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh # drop the newest cluster sudo pg_dropcluster $NEW_PG_VERSION main --stop # upgrade the old cluster to the new version sudo pg_upgradecluster $CURRENT_PG_VERSION main # drop the old cluster sudo pg_dropcluster $CURRENT_PG_VERSION main # remove old PostgreSQL version from the system sudo apt purge postgresql-${CURRENT_PG_VERSION} postgresql-client-${CURRENT_PG_VERSION}