To use pg_upgrade
for migrating from PostgreSQL 11 to PostgreSQL 15, follow these steps:
Install PostgreSQL 15: Install the new PostgreSQL version alongside the old one without removing PostgreSQL 11.
Prepare the Environment:
Run pg_upgrade
:
pg_upgrade
tool provided with PostgreSQL 15.Example Command:
pg_upgrade \\\\
--old-datadir=/var/lib/pgsql/11/data \\\\
--new-datadir=/var/lib/pgsql/15/data \\\\
--old-bindir=/usr/lib/postgresql/11/bin \\\\
--new-bindir=/usr/lib/postgresql/15/bin
Post-Upgrade Steps:
ANALYZE
to update statistics.Testing:
Make sure to backup your data before starting the upgrade process. Additionally, testing the upgrade in a non-production environment first is highly recommended.