Hi, I'm trying to upgrade PostgreSQL from 17 to 18. The steps I did
were:
apk add postgresql18
service postgresql stop
pg_versions set-default 18
mv /var/lib/postgresql/17/data /var/lib/postgresql/17/olddata
mkdir -p /var/lib/postgresql/18/{data,tmp}
chown -R postgres:postgres /var/lib/postgresql/18
su postgres
cd /var/lib/postgresql/18/tmp
initdb -D /var/lib/postgresql/18/data --locale=en_GB.UTF-8 --encoding=UTF8 --data-checksums
pg_upgrade -b /usr/libexec/postgresql17 -B /usr/libexec/postgresql18 -d /var/lib/postgresql/17/olddata -D /var/lib/postgresql/18/data
The output is
Performing Consistency Checks
-----------------------------
Checking cluster versions
This utility can only upgrade to PostgreSQL version 18.
Failure, exiting
Any idea what I'm doing wrong?
Thanks in advance.
Hi,
I just tried to replicate your steps and it works on my system.
Can you verify that /usr/libexec/postgresql is a symlink to
/usr/libexec/postgresql18 after running `pg_versions set-default 18` and that
/usr/bin/initdb is a symlink to /usr/libexec/postgresql/initdb?
Can you verify that /var/lib/postgresql/18/data/PG_VERSION contains `18`?
Jakub
On Fri, 2026-03-13 at 14:14 +0000, revsuine wrote:
> Hi, I'm trying to upgrade PostgreSQL from 17 to 18. The steps I did
> were:
>
> apk add postgresql18
> service postgresql stop
> pg_versions set-default 18
> mv /var/lib/postgresql/17/data /var/lib/postgresql/17/olddata
> mkdir -p /var/lib/postgresql/18/{data,tmp}
> chown -R postgres:postgres /var/lib/postgresql/18
> su postgres
> cd /var/lib/postgresql/18/tmp
> initdb -D /var/lib/postgresql/18/data --locale=en_GB.UTF-8 --encoding=UTF8 --data-checksums
> pg_upgrade -b /usr/libexec/postgresql17 -B /usr/libexec/postgresql18 -d /var/lib/postgresql/17/olddata -D /var/lib/postgresql/18/data
>
> The output is
>
> Performing Consistency Checks
> -----------------------------
> Checking cluster versions
> This utility can only upgrade to PostgreSQL version 18.
> Failure, exiting
>
> Any idea what I'm doing wrong?
>
> Thanks in advance.