Skip to content

Instantly share code, notes, and snippets.

@isDipesh
Last active November 24, 2025 10:19
Show Gist options
  • Select an option

  • Save isDipesh/ec1d36b8cdd4a1f81dc2171ef588c04a to your computer and use it in GitHub Desktop.

Select an option

Save isDipesh/ec1d36b8cdd4a1f81dc2171ef588c04a to your computer and use it in GitHub Desktop.
Postgres cluster upgrade for new Postgres version on Arch linux
# If postgis is used
yay -S postgis-old-upgrade
sudo su
systemctl stop postgresql
mv /var/lib/postgres/data /var/lib/postgres/olddata
mkdir /var/lib/postgres/data /var/lib/postgres/tmp
chown postgres:postgres /var/lib/postgres/data /var/lib/postgres/tmp
sudo su postgres
cd /var/lib/postgres/tmp
# Use --no-data-checksums if pg was initialized without page checksums
initdb -D /var/lib/postgres/data --locale=C.UTF-8 --encoding=UTF8 --no-data-checksums
# Replace 18 with old pg version number
pg_upgrade -b /opt/pgsql-18/bin -B /usr/bin -d /var/lib/postgres/olddata -D /var/lib/postgres/data
systemctl start postgresql
psql -f update_extensions.sql
./delete_old_cluster.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment