PostgreSQL not running (UPdate 2025-12-08)

I run the UPdate 2025-12-08, that runs. To prepare the major UPdate for PostgreSQL, I delayed those packages for now and edited /etc/pacman.conf

IgnorePkg   = postgresql
IgnorePkg   = postgresql-libs
IgnorePkg   = postgresql-old-upgrade

So I have still

$ pamac info postgresql Name : postgresql Version : 17.5-5

But:

$ systemctl status postgres Unit postgres.service could not be found.

Because that’s incorrect service name, the correct one is postgresql, so:

systemctl status postgresql
1 Like

Damn, thanks a lot.

$ systemctl status postgresql
× postgresql.service - PostgreSQL database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Fri 2025-12-12 16:48:37 CET; 3h 48min ago
 Invocation: cb1eede82a604b4685e2daf36bb6d54e
       Docs: man:postgres(1)
    Process: 954 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=0/SUCCESS)

    Process: 958 ExecStart=/usr/bin/postgres -D ${PGROOT}/data (code=exited, status=127)
   Main PID: 958 (code=exited, status=127)
   Mem peak: 2.1M
        CPU: 120ms

Dez 12 16:48:37 systemd[1]: Starting PostgreSQL database server...
Dez 12 16:48:37 postgres[958]: /usr/bin/postgres: error while loading shared libraries: libicui18n.s>
Dez 12 16:48:37 systemd[1]: postgresql.service: Main process exited, code=exited, status=127/n/a
Dez 12 16:48:37 systemd[1]: postgresql.service: Failed with result 'exit-code'.
Dez 12 16:48:37 systemd[1]: Failed to start PostgreSQL database server.

lines 1-16/16 (END)

You need to update all packages, with this big update you don’t have the choice to delay the update of postgresql packages. After the complete update, upgrade the database, via the normal steps.

Thank you, but

what do you mean with normal steps? In the past, I used postgresql-old-upgrade but this needs a running postgresql.service

This is the preferred way with pg_upgrade

You don’t need a running DB, but Postgressql needs to be stopped cleanly.

But since it is now a little bit late, you might need to do it the manual way.

1 Like

Thank you @xabbu,

I tried my best but did not get it:

UPdated the three packages:

$ pamac checkupdates
   3 Aktualisierungen verfügbar:
      postgresql              17.5-5 -> 18.1-1  extra
      postgresql-libs         17.5-5 -> 18.1-1  extra
      postgresql-old-upgrade  16.9-2 -> 17.7-1  extra
$ pamac update

As I’m using an user-defined data-dir, I did

$ sudo -i
# mv /mnt/Daten/Technik/PostgreSQL/data /mnt/Daten/Technik/PostgreSQL/data17
# mkdir /mnt/Daten/Technik/PostgreSQL/data
# chown postgres:postgres /mnt/Daten/Technik/PostgreSQL/data
exit
exit

$ sudo -i -u postgres
[postgres@XYZ ~]$ initdb -D /mnt/Daten/Technik/PostgreSQL/data --locale=C.UTF-8 --encoding=UTF8 --data-checksums
   Erfolg. Sie können den Datenbankserver jetzt starten mit:
      pg_ctl -D /mnt/Daten/Technik/PostgreSQL/data -l logdatei start

[postgres@XYZ ~]$ /opt/pgsql-17/bin/pg_ctl -D /mnt/Daten/Technik/PostgreSQL/data17/ start
   server started

[postgres@IBM-T14s ~]$ pg_dumpall -h /tmp -f /tmp/old_backup.sql

[postgres@IBM-T14s ~]$ /opt/pgsql-17/bin/pg_ctl -D /mnt/Daten/Technik/PostgreSQL/data17/ stop
   server stopped

But the server does not start and /data is almost empty, /data17 is at 2,2 GB

$ systemctl start postgresql.service

$ systemctl status postgresql.service
× postgresql.service - PostgreSQL database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Tue 2025-12-16 14:41:57 CET; 35s ago
 Invocation: d8acf076f5654353b90d68dce2c1d976
       Docs: man:postgres(1)
    Process: 27182 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=1/FAILUR>
   Mem peak: 2.2M
        CPU: 39ms

How to solve this?

The > at the end of this line suggests it has been truncated. I would expect postgresql-check-db-dir to report why it failed. Can you re-run systemctl status postgresql.service but in a wider terminal window?

In the postgresql.service file it sets PGROOT before running the DB check - you might want to check it is set to /mnt/Daten/Technik/PostgreSQL.

Or rerun with --no-pager --full flags:

systemctl --no-pager --full status postgresql.service
1 Like

Well i can’t figure out how the data should have been migrated since there seems to be only the dumping part. Anyway, i have a somewhat similar setup and did it like so

# su postgres
[postgres]$ cd /home/postgres
[postgres]$ mv data olddata
[postgres]$ mkdir data
[postgres]$ mkdir tmp
[postgres]$ cd tmp
[postgres]$ initdb -D /home/postgres/data
[postgres]$ pg_upgrade -b /opt/pgsql-PG_VERSION/bin -B /usr/bin -d /home/postgres/olddata -D /home/postgres/data

The differences are creating a temporary working directory and using the single pg_upgrade command (which is said to be the recommended way - notice PG_VERSION stands for the old version). Notice also that as of version 18 the check sums are turned on by default. Unless you had them turned on for the old 17 version already you need the extra step of turning check sums off temporarily for the migration. Notice also that i didn’t turn on the service. This comes only after the pg_upgrade but you tried a different path - but if you dump that is export where is the import?

There is more than one way to migrate the data, and the OP seems to be using the pg_dumpall way: PostgreSQL: Documentation: 18: 18.6. Upgrading a PostgreSQL Cluster

But to proceed with that, they now need the new PostgreSQL service to be running.

I’ve never tried this method, but it is in the manual so I guess should work.


$ systemctl status postgresql.service

× postgresql.service - PostgreSQL database server

     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled)

     Active: failed (Result: exit-code) since Tue 2025-12-16 15:09:10 CET; 3h 21min ago

 Invocation: f2cb76ee5d094f5b82a77bc02539a94a

       Docs: man:postgres(1)

    Process: 944 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=1/FAILURE)

   Mem peak: 2.1M

        CPU: 63ms
Dez 16 15:09:10 XYZ systemd[1]: Starting PostgreSQL database server...
Dez 16 15:09:10 XYZ postgres[944]: An old version of the database format was found.
Dez 16 15:09:10 XYZ postgres[944]: See https://wiki.archlinux.org/index.php/PostgreSQL#Upgrading_PostgreSQL
Dez 16 15:09:10 IBM-T14s systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
Dez 16 15:09:10 IBM-T14s systemd[1]: postgresql.service: Failed with result 'exitcode'.

Dez 16 15:09:10 IBM-T14s systemd[1]: Failed to start PostgreSQL database server.

How to do that:

In the postgresql.service file it sets PGROOT before running the DB check - you might want to check it is set to /mnt/Daten/Technik/PostgreSQL.

The postgresql.service file on my system is located here: /usr/lib/systemd/system/postgresql.service. Yours may be at a different location. In my file I see this line (it is just a text file so you can use whatever you want to view it):

Environment=PGROOT=/var/lib/postgres

And it is important it is correct for you database. My database files were initialised with initdb -D /var/lib/postgres/data - note PGDATA does not have the data part.

The postgresql-check-db-dir script (in my system) checks the contents of the PG_VERSION file; for instance on my system that file says 18 (I used sudo because only the postgres users has access - I could have switched user but just used sudo)

~ > sudo cat /var/lib/postgres/data/PG_VERSION
18

Somewhere there is a mismatch on your system - either the check is using the wrong directory, or the initdb used another version, or something else.

Edited to add:
We know there is a mismatch because the status included this:

Dez 16 15:09:10 XYZ postgres[944]: An old version of the database format was found.

But:

$ sudo cat /var/lib/postgres/data/PG_VERSION 
17 

And in the data-dir that I defined:

sudo cat /mnt/Daten/Technik/PostgreSQL/data/PG_VERSION
18

Why this difference?

How to do that:

The postgresql.service file on my system is located here: /usr/lib/systemd/system/postgresql.service. Yours may be at a different location. In my file I see this line (it is just a text file so you can use whatever you want to view it):

Mine /usr/lib/systemd/system/postgresql.service is the same:

Environment=PGROOT=/var/lib/postgres

I’m totally confused now …

Without knowing the history of you installation I can’t say why.

I can say that you need to make things consistent. You used initdb to set the data directory to /mnt/Daten/Technik/PostgreSQL/data, and that path seemed to be what was being used before. This assumes that this command did actually dump your data:

pg_dumpall -h /tmp -f /tmp/old_backup.sql

I see the destination of your data was set to /tmp/old_backup.sql, and /tmp is generally completely cleared when you re-boot.

I would first check that the dumped data exists and looks right; pg_dumpall dumps the data as a text file so I would check the file looks like it contains you data. If not, I would re-do those steps to ensure you have a valid dump, and I would personally not put it in /tmp in case you need to re-boot at some point.

Once you are sure your data is safe, I would make a backup copy of postgresql.service and then edit the original to have something like this:

Environment=PGROOT=/mnt/Daten/Technik/PostgreSQL

I would then re-start the service and if the status says it is running, you can continue to the next step to import your data.

Thank you @Phemisters, I have a dumpall available

sudo -u postgres pg_dumpall > "/mnt/Daten/Datenbanken/Backup/PostgreSQL/pgDump ALL.sql"

This file is more than 1 GB, should have the data …

Can I reset the postgres-settings, clear /mnt/Daten/Technik/PostgreSQL/data and restore this dumall? If so, how …

Firstly, is the service status now good?

Secondly, I don’t think you need to clear /mnt/Daten/Technik/PostgreSQL/data - it was initialised by the initdb.

Thirdly, I don’t know what settings you have to restore - depends on what you might have changed. But, yes restore any custom settings before the import of data, I guess.

Fourthly, if the service is running then you can import the data with psql with the name of the file you dumped it to, something like this:

psql -f use-the-name-of-the-pg_dumpall-file-here

No, how to achieve this?

Did you edit the /usr/lib/systemd/system/postgresql.service file? If so, post the full output of:

systemctl status postgresql.service --no-pager --full 

and perhaps share the changes made to /usr/lib/systemd/system/postgresql.service.

NO, I did not. Should I ….

$ systemctl status postgresql.service --no-pager --full
× postgresql.service - PostgreSQL database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Tue 2025-12-16 15:09:10 CET; 1 day 2h ago
 Invocation: f2cb76ee5d094f5b82a77bc02539a94a
       Docs: man:postgres(1)
    Process: 944 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=1/FAILURE)
   Mem peak: 2.1M
        CPU: 63ms
Dez 16 15:09:10 XYZ systemd[1]: Starting PostgreSQL database server...
Dez 16 15:09:10 XYZ postgres[944]: An old version of the database format was found.
Dez 16 15:09:10 XYZ postgres[944]: See https://wiki.archlinux.org/index.php/PostgreSQL#Upgrading_PostgreS
QL
Dez 16 15:09:10 XYZ systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
Dez 16 15:09:10 XYZ systemd[1]: postgresql.service: Failed with result 'exit-code'.
Dez 16 15:09:10 XYZ systemd[1]: Failed to start PostgreSQL database server.