Step-by-Step Guide to Migrating from PostgreSQL 11 to 15 Using pg_upgrade

Introduction

To use pg_upgrade for migrating from PostgreSQL 11 to PostgreSQL 15, follow these steps:

Runbook to Migrate from PostgreSQL 11 to 15

  1. Install PostgreSQL 15: Install the new PostgreSQL version alongside the old one without removing PostgreSQL 11.
  2. Prepare the Environment:
    • Stop the PostgreSQL 11 server.
    • Ensure both versions have the same locale and encoding settings.
  3. Run pg_upgrade:
    • Use the pg_upgrade tool provided with PostgreSQL 15.
    • Run it as the same user owning the database processes.
    • Specify the old and new data directories and server binaries.
  4. Example Command:
  5. Post-Upgrade Steps:
    • Start the PostgreSQL 15 server.
    • Run ANALYZE to update statistics.
    • Check for any deprecated features or compatibility issues.
  6. Testing:
    • Test your applications against the new server.
    • Monitor for performance and stability.

Conclusion

Make sure to backup your data before starting the upgrade process. Additionally, testing the upgrade in a non-production environment first is highly recommended.

About Shiv Iyer 444 Articles
Open Source Database Systems Engineer with a deep understanding of Optimizer Internals, Performance Engineering, Scalability and Data SRE. Shiv currently is the Founder, Investor, Board Member and CEO of multiple Database Systems Infrastructure Operations companies in the Transaction Processing Computing and ColumnStores ecosystem. He is also a frequent speaker in open source software conferences globally.