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.
B. After OS updates and reboots, merge the changed config files and patch system:
4. Upgrade the packages (including postgreSQL):
A.
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]
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
-----
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.