--- title: "Polarity General - Upgrade PostgreSQL Server to v15 (v4 to v5 Preparation)" slug: "polarity-upgrade-postgresql-server-to-v15" description: "Polarity General users can upgrade their PostgreSQL database from 9.x/13 to version 15 on CentOS 7/RHEL 7. Follow step-by-step instructions to backup, install PGDG repo, run pg_upgrade." tags: ["EL 7", "Polarity Enterprise", "Polarity Server", "Polarity Upgrade from v4"] updated: 2025-08-15T20:34:55Z published: 2025-08-15T20:34:55Z canonical: "knowledge.threatconnect.com/polarity-upgrade-postgresql-server-to-v15" --- > ## Documentation Index > Fetch the complete documentation index at: https://knowledge.threatconnect.com/llms.txt > Use this file to discover all available pages before exploring further. # Upgrade PostgreSQL Server to v15 *CentOS 7 and RHEL 7 Guide to upgrade from PostgreSQL 9.x/13 to PostgreSQL 15 on the v4 server.* Older installations of Polarity Server v4 will likely be running PostgreSQL 9.x, which has reached End of Support. We recommend upgrading to PostgreSQL 15 (the default for newer releases of Polarity Server). This guide will step you through updating an existing PostgreSQL 9.5 database server located on the Polarity Server to PostgreSQL 15. **Note** **This guide is for v4 servers on an EL 7 distro (such as CentOS 7, RHEL 7, AL2, etc.) to prepare them for the upgrade to v5.** Customers running RHEL 8, Oracle Linux 8, or other EL 8 distro should already be running PostgreSQL v13 and can upgrade to v15 but is not required to complete the upgrade from Polarity Server v4 to Polarity Server v5. ## Before You Begin Log into the Polarity Server CLI as root or a user with sudo access. Take a full backup of the Polarity Server v4 database before you begin. ```shell su - postgres -c '/app/polarity-server/data/backups/db-backup.sh' ``` Install the latest Polarity Server v4.x RPMs. Note If you are running Polarity Server v5, this upgrade has already occurred as a part of the upgrade process. ## Upgrade Steps ### Prepare Stop the Polarity Server and PostgreSQL 9.5 services ```shell systemctl stop polarityd systemctl stop postgresql-9.5 ``` ### Install the latest PostgreSQL v15 packages If you have not already installed the PGDG repository that downloads and installs PostgreSQL YUM packages directly from the PostgreSQL YUM repository, or need to update it please run: ```shell yum --disablerepo=* install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y ``` After the PostgreSQL repo is updated, you can install the PostgreSQL 15: ```shell yum install postgresql15 postgresql15-server ip4r_15 postgresql15-libs postgresql15-contrib -y ``` Initialize the PostgreSQL 15 server ```shell su - postgres -c "/usr/pgsql-15/bin/initdb -D /var/lib/pgsql/15/data" ``` ### Upgrade and Transition Data to the PostgreSQL 15 Server The first and second commands are exactly the same, except for the --check option given on the first execution. This option checks whether or not the execution will succeed without making any actual changes. Note The backslashes (\) at the end of each line allow the command to continue on the next line. This allows us to display the whole command in chunks for clarity. ```shell time /usr/pgsql-15/bin/pg_upgrade \ --old-bindir /usr/pgsql-9.5/bin \ --new-bindir /usr/pgsql-15/bin \ --old-datadir /var/lib/pgsql/9.5/data \ --new-datadir /var/lib/pgsql/15/data --link --check ``` If the output from above shows *Clusters are compatible*, proceed to the next step to run the upgrade. ```shell time /usr/pgsql-15/bin/pg_upgrade \ --old-bindir /usr/pgsql-9.5/bin \ --new-bindir /usr/pgsql-15/bin \ --old-datadir /var/lib/pgsql/9.5/data \ --new-datadir /var/lib/pgsql/15/data --link ``` Note You may see a message saying you must "update your extensions". The message will look like this: Your installation contains extensions that should be updated with the ALTER EXTENSION command. The file update_extensions.sql when executed by psql by the database superuser will update these extensions. If you see this message, it will be addressed in the next step. ### Transition Server Processes Disable and the PostgreSQL 9.5 database server, start the PostgreSQL 15 database server, and restart the Polarity Service: ```shell systemctl disable --now postgres-9.5 systemctl enable --now postgres-15 systemctl restart polarityd ``` If you need to update your extensions (see message from above), run the following command now that the PostgreSQL 15 database is running: ```shell su - postgres -c "psql -f /var/lib/pgsql/update_extensions.sql" ``` Refresh the user stats materialized view: ```shell su - postgres -c 'psql -d breach -c "REFRESH MATERIALIZED VIEW polarity.user_stats;"' ``` Problems? *If there have been any errors to this point, please contact* ***Polarity Support*** *for assistance.* ### Finish Up Confirm the PostgreSQL 15 database and Polarity services are running: ```shell systemctl status postgresql-15 systemctl status polarityd ``` You should see the new postgresql-15 service running and active. Attempt to log into the Polarity User Interface (Web or Desktop Client) and making some sample searches to confirm that your Polarity Server is functional. Once you have confirmed this, delete the older version of PostgreSQL to avoid potential complications during the upgrade process to Polarity Server v5: ```shell yum remove postgresql95 -y rm -rf /var/lib/pgsql/9.5 ```