Introduction
The latest stable version of PostgreSQL, version 17, has recently been released. As an ardent follower of new releases, I naturally felt compelled to upgrade to the latest version. This document chronicles the process of upgrading my Postgres database from version 16 to 17, including the data migration.
Establishing the New Database
- My database primarily utilizes Docker for launch, with the following Docker Compose script:
yamlversion: '3.8'
services:
# Legacy Database
postgres16:
container_name: postgres16
image: postgres:16-alpine
volumes:
- /data/postgre16:/var/lib/postgresql/data
ports:
- '5432:5432'
environment:
- POSTGRES_PASSWORD=xxxxxx
- POSTGRES_DB=example
restart: always
networks:
- pgsql
# New Database, Port Can Be Arbitrarily Defined, Default Port 5432 Will Be Used After Data Migration
postgres17:
container_name: postgres17
image: postgres:17-alpine
volumes:
- /data/postgre17:/var/lib/postgresql/data
ports:
- '5433:5432'
environment:
- POSTGRES_PASSWORD=xxxxxx