PostgreSQL for Windows

Upgrade or Migrate PostgreSQL on Windows

Two paths: safer dump/restore or faster in-place with pg_upgrade. Back up first, verify compatibility, and keep a rollback plan for Windows 10/11.

Tip: Keep the old data directory untouched until the new version is fully validated.

Pre‑upgrade checklist

  • Confirm Windows 10/11 (64‑bit) and available disk space.
  • Back up databases and roles; test a restore if possible.
  • Stop background jobs and client connections during upgrade.
  • Verify extension compatibility with the target version.
  • Plan for downtime and have a rollback procedure.

Path A — Safer dump/restore migration

  1. Back up roles/globals to capture users and permissions.
  2. Back up each database to portable files. Keep them safe.
  3. Install the new version side-by-side; initialize a fresh data directory.
  4. Restore roles and databases into the new cluster.
  5. Validate with application smoke tests and integrity checks.
  6. Switch clients to the new instance; keep the old offline for rollback until confident.

This path is simple and predictable, at the cost of longer downtime on large datasets.

Path B — In‑place upgrade with pg_upgrade (overview)

  1. Stop the old service. Ensure no processes hold locks on the data directory.
  2. Install the new version (binaries and tools) without removing the old.
  3. Run pg_upgrade checks to validate compatibility and directory paths.
  4. Perform the upgrade following the tool’s prompts and guidance.
  5. Analyze and reindex where recommended to rebuild statistics and indexes.
  6. Start the new service and test with your applications before decommissioning the old cluster.

pg_upgrade is much faster but requires strict adherence to its checklist. Always keep backups and a tested rollback plan.

Post‑migration checks

Connectivity

Connect locally and remotely, run critical queries, and verify performance against benchmarks.

Extensions

Upgrade or reinstall extensions as needed; confirm versions and availability.

Maintenance

Rebuild statistics and consider reindexing for large or critical tables when advised.

Troubleshooting — quick answers

Service still running

Stop the PostgreSQL Windows service and ensure no leftover processes are locking files before upgrading.

Permission denied

Run tools with sufficient privileges and ensure the service account can access both old and new data directories.

Incompatible jump

Some version jumps need intermediate steps. Review compatibility notes and consider dump/restore if pg_upgrade flags issues.

Related guides

Disclaimer: This is an unofficial resource. PostgreSQL is a registered trademark of the PostgreSQL Community Association of Canada. Links may include affiliate tracking.