Upgrade an external database to PostgreSQL 18
From release 6.4.4, Email Gateway Security supports PostgreSQL 18 as an external database. An upgrade of Email Gateway Security does not change the external database server. Systems that were upgraded from an earlier release continue to operate on their PostgreSQL 14 server. The database administrator should upgrade this server to PostgreSQL 18 in a maintenance window. For the supported PostgreSQL versions, see Prerequisites.
This page is only for an external database server. For the embedded database, see Upgrade the embedded database to PostgreSQL 18.
Overview
Supported versions
Email Gateway Security 6.4.4 supports the PostgreSQL major version 18, minor release 18.4 or later
On systems that were upgraded from an earlier release, Email Gateway Security still works with the major version 14 until the database server is upgraded. But PostgreSQL 14 is not supported, because it has no vendor support any more
PostgreSQL 15, 16 and 17 are not supported
A later release of Email Gateway Security will not operate on PostgreSQL 14
Who needs the upgrade
Systems with an external database server that still runs PostgreSQL 14. These signs show it:
The management console shows the Database server upgrade required notification. You cannot dismiss it

The About product dialog shows a 14.x release in the PostgreSQL Version row. To open the dialog, click the user icon in the upper right corner of the management console, then click About product

During the upgrade of Email Gateway Security from a 6.x release, the installer shows a notification about the database version in a message box after you click Install. For details see Installation

Who does the upgrade
The database administrator of your organization upgrades the database server. Email Gateway Security does not upgrade an external database server. The Upgrade-EmbeddedDatabase.ps1 script is only for the embedded database, and it refuses to run on a system with an external database.
Before you start
Upgrade all Email Gateway Security instances that use the database to release 6.4.4 or later. Release 6.4.4 is the first release that supports PostgreSQL 18. OPSWAT cannot guarantee that earlier releases work with it. For details see Installation. If the upgrade stops with Access is denied, see Troubleshooting below
Plan a maintenance window. While the database server is not available, Email Gateway Security cannot process emails
Make a full backup of the database server
We recommend that you stop the Email Gateway Security services on all instances that use the database. If you do not stop them, they cannot use the database during the upgrade. For details see Scalable deployment operation
Upgrade methods
Use one of the methods that the PostgreSQL documentation describes. For an overview, see Upgrading a PostgreSQL Cluster.
pg_upgrade: converts the existing database cluster to the new major version. This is usually the fastest method
Dump and restore: pg_dumpall, pg_dump and pg_restore. Use the programs of PostgreSQL 18 to make the dump
Logical replication: copies the data to a running PostgreSQL 18 server. This method needs more preparation, but the downtime is short
Notes for Email Gateway Security
Address: keep the host name and the port of the database server. Email Gateway Security uses the values that you gave at the installation, and an upgrade of Email Gateway Security does not ask for them again
Database user: Email Gateway Security connects with the same database user and password as before. With dump and restore or with logical replication, copy the roles first, for example with
pg_dumpall --globals-onlypg_trgm: the new server must have the pg_trgm extension. On a new database, a superuser must create it before Email Gateway Security starts:
CREATE EXTENSION pg_trgm WITH SCHEMA pg_catalog;For details see pg_trgmpgcrypto: Email Gateway Security 6.4.4 does not need the pgcrypto extension any more. A database from an earlier release can still contain it. Then the new server must also have it for pg_upgrade and for a restore. The standard PostgreSQL packages contain it
Statistics: after a restore or after logical replication, run ANALYZE on the Email Gateway Security database
After the upgrade
Start the Email Gateway Security services on all instances, if you stopped them
Check that all instances connect to the database and that emails are processed, for example on the Email History page
Check that the Database server upgrade required notification is gone. The About product dialog shows the PostgreSQL 18 minor release, for example 18.7

Troubleshooting
The upgrade of Email Gateway Security stops with "Access is denied"
Symptom: you upgrade an Email Gateway Security system with an external database from an earlier 6.x release. After you click Install, the installer shows this message and stops:
The installer cannot connect to the database server <host>:<port> to read its version. The installation stopped, and no change was made. Make sure that the database server operates and that the connection settings are correct. Details: Access is denied
Cause: before it changes anything, the installer reads the version of the database server. For this, it starts its own copy of psql.exe from a temporary folder, C:\Windows\Installer\MSI<number>.tmp-\. The attack surface reduction (ASR) rule Use advanced protection against ransomware of Microsoft Defender can block this program. Then Windows refuses to start it, and the installer reports Access is denied. The connection settings and the password of the database are not the cause.
How to check it:
In Windows Security > Protection history, look for an entry Risky action blocked with these details: Blocked by: Attack surface reduction, Rule: Use advanced protection against ransomware, and the affected item
C:\Windows\Installer\MSI<number>.tmp-\psql.exeIn a verbose log of the installer, the error is
System.ComponentModel.Win32Exception (0x80004005): Access is deniedatSystem.Diagnostics.Process.StartWithCreateProcess. To write such a log, start the installer from an administrator command prompt:msiexec /i "<path of the .msi file>" /l*v "C:\Temp\egs-upgrade.log"
What to do:
Ask the administrator of Microsoft Defender in your organization to set the rule Use advanced protection against ransomware to Audit mode on this server for the time of the upgrade, or to add an exclusion for the
psql.exethat the installer starts. The name of the temporary folder changes with each run of the installer. If the protection history says Your administrator has blocked this action, the rule comes from a central policy, and you cannot change it on the serverRun the installer again. The stopped attempt did not change the installed system
After the upgrade, ask the administrator to set the rule back to its earlier mode, or to remove the exclusion