1

Topic: PGSQL 15 -> 16 Upgrade w/ OpenBSD 7.5

- iRedMail 1.7.1
- Deployed with downloadable installer
- OpenBSD 7.4 -> 7.5
- Store mail accounts in PGSQL
- Web server Nginx
- Manage mail accounts with command line interface
====

Hello Sir, I hope that you are well.

I recently upgraded from iRedMail 1.6.8 to 1.7.1 and from OpenBSD 7.3 to 7.4.

However, when attempting to upgrade to OpenBSD 7.5, the upgrade from PGSQL 15 to 16 failed with the following error:

"There seems to be a postmaster servicing the new cluster. Please shutdown that postmaster and try again. Failure, exiting"

I was not able to resolve the error, and reverted to a OpenBSD 7.4 backup with PGSQL 15 and iRedMail 1.7.1.

I am about to try again to upgrade to OpenBSD 7.5 and PGSQL 16.

Is this a good guide to follow? <https://dev.to/nabbisen/postgresql-on-o … grade-4484>

Do I have to make any iRedMail specific changes before or after? Do I have to shut down iRedMail services after upgrading to OpenBSD 7.5 and before upgrading to PGSQL 16?

Thank you for your wonderful software and support. I'm sure this will also help to migrate to PGSQL 17 in the future when it is ported to OpenBSD.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: PGSQL 15 -> 16 Upgrade w/ OpenBSD 7.5

Backup the databases first, then you're free to try.

3 (edited by Neovana 2025-01-15 17:14:47)

Re: PGSQL 15 -> 16 Upgrade w/ OpenBSD 7.5

I finally figured it out. Here is how to upgrade postgresql from 15 to 16 with OpenBSD and iRedMail:

1. Backup iRedMail server.

2. Upgrade iRedMail to 1.7.1.

3. Upgrade OpenBSD from 7.4 to 7.5:
A.

$ doas sysupgrade

B. After OS updates and reboots, merge the changed config files and patch system:

$ doas sysmerge
$ doas syspatch

4. Upgrade the packages (including postgreSQL):
A.

$ doas pkg_add -u

B. During the updating of the packages, you'll be asked:

postgresql-server-16.3: Updating across a major version - data migration needed, see the pkg-readme.
Do you want to update now ? [y/N/a]

y

5. Install pg_upgrade:

$ doas pkg_add postgresql-pg_upgrade

6. Stop postgresql:

$ doas rcctl stop postgresql

7. Move the postgresql data folder:

$ doas mv /var/postgresql/data /var/postgresql/data-15

8. Create a new postgresql data folder and initialize a new database using the iRedMail postgresql admin user (different than other installs which use the admin account name "postgre"):

$ doas su _postgresql -c \
"mkdir /var/postgresql/data && \
cd /var/postgresql && \
initdb -D /var/postgresql/data -U _postgresql \
-A scram-sha-256 -E UTF8 -W"

Note that "_postgresql" is both the OS user account and the postgresql db admin account.

9. Temporarily allow _postgresql db account to have free reign while updating in the old db.
A.

$ doas nano /var/postgresql/data-15/pg_hba.conf

B. At the bottom of the pg_hba.conf file will be the permissions section headed by:

# TYPE  DATABASE        USER            ADDRESS

Add this line to the top of the list (just under the above header):

local all _postgresql trust

C. Exit nano.

D. Copy the same config file that you've just edited to the new db:

$ doas cp -p /var/postgresql/data-15/pg_hba.conf \
/var/postgresql/data/

10. Create soft-links to the db certificate and key:

$ doas ln -s /etc/ssl/iRedMail_CA_PostgreSQL.pem \
/var/postgresql/data/server.crt && \
doas ln -s /etc/ssl/iRedMail_PostgreSQL.key \
/var/postgresql/data/server.key

11. Upgrade the postgresql 15 db to postgresql 16:

$ doas su _postgresql -c "cd /var/postgresql && \
pg_upgrade -b /usr/local/bin/postgresql-15/ \
-B /usr/local/bin -U _postgresql \
-d /var/postgresql/data-15/ -D /var/postgresql/data"

12. Remove the free reign for the _postgresql db account:
A.

$ doas nano /var/postgresql/data-15/pg_hba.conf

B. At the bottom of the pg_hba.conf file will be the permissions section headed by:

# TYPE  DATABASE        USER            ADDRESS

Remove this line from the top of the list (just under the above header):

local all _postgresql trust

C. Exit nano.

D. Copy the same config file that you've just edited to the new db:

$ doas cp -p /var/postgresql/data-15/pg_hba.conf \
/var/postgresql/data/

13. Start up postgresql (16):

$ doas rcctl start postgresql

14. Reboot

$ doas reboot

-----

The problem for me was that I wasn't using the iRedMail DB admin username. Hopefully this helps someone else - or helps me when it comes time to upgrade to postgresql 17.

4

Re: PGSQL 15 -> 16 Upgrade w/ OpenBSD 7.5

Thanks for sharing. smile