postgresql upgrade

TIFU by letting pacman upgrade the postgresql a major version (13->14). Then the postgresql service failed to start.. Anyways here is the fix.

also a nice thing in the AUR: the postgresql-old-upgrade package. It provides the binary for the older version of psql under/opt/postgresql{VERSION}

Before doing anything stop the postgresql service.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
mv /var/lib/postgres/data /var/lib/postgres/olddata
mkdir /var/lib/postgres/data /var/lib/postgres/tmp
chown postgres:postgres /var/lib/postgres/data /var/lib/postgres/tmp

# SWITCH TO postgres user: sudo -iu postgres

cd /var/lib/postgres/tmp

initdb -D /var/lib/postgres/data --PARAMETERS_USED_TO_INIT_DB

pg_upgrade -b /opt/pgsql-PG_VERSION/bin -B /usr/bin -d /var/lib/postgres/olddata -D /var/lib/postgres/data

Then start postgresql.service again

Thank you, archwiki.

https://wiki.archlinux.org/title/PostgreSQL#Upgrading_PostgreSQL

edited 20.04.2024
created 24.04.2022
EOF
[+] click to leave a comment [+]
the comment system on this blog works via email. The button
below will generate a mailto: link based on this page's url 
and invoke your email client - please edit the comment there!

[optional] even better, encrypt the email with my public key

- don't modify the subject field
- specify a nickname, otherwise your comment will be shown as   
  anonymous
- your email address will not be disclosed
- you agree that the comment is to be made public.
- to take down a comment, send the request via email.

>> SEND COMMENT <<