Skip to content

Instantly share code, notes, and snippets.

@camilonova
Created October 16, 2024 15:22
Show Gist options
  • Save camilonova/6704eaae01e2a6a5ef92f4a9783f23bc to your computer and use it in GitHub Desktop.
Save camilonova/6704eaae01e2a6a5ef92f4a9783f23bc to your computer and use it in GitHub Desktop.
Upgrade postgres to 16
# Create the file repository configuration:
sudo sh -c 'echo "deb https://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
# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql-16
# Check
sudo pg_lsclusters
# Stop new cluster
sudo pg_dropcluster 16 main --stop
# Upgrade
sudo pg_upgradecluster 14 main
# Drop old cluster
sudo pg_dropcluster 14 main
# Remove old packages
sudo apt purge postgresql-14 postgresql-client-14
# Check
sudo pg_lsclusters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment