Skip to main content

This article applies to version 6.

Available in:

Small Business
Code42 Support

PostgreSQL upgrade on Red Hat

This article applies to version 6.

Available in:

Small Business


This article describes how to upgrade a PostgreSQL server on a Red Hat Enterprise Linux system.


  • These instructions describe upgrading PostgreSQL 9.5 to PostgreSQL 9.6 on an RHEL 7.5 system. Precise steps for other environments may differ.
  • To upgrade PostgreSQL, you need to know:
    • The name and password for the PostgreSQL database that serves your Code42 authority server.
    • The name and password for the user who owns that database.

Non-Code42 products
​Information about products from other manufacturers is intended as a resource to help you get the most out of Code42 products. However, our Customer Champions cannot provide direct assistance for these products. Contact your Customer Success Manager (CSM) at, or the product's manufacturer.

Step 1: Stop your Code42 authority server

  1. Sign in to the operating system where your Code42 authority server runs.
    Use an identity with sudo privileges.
  2. Stop the authority server with this command:
sudo /etc/init.d/proserver stop

Step 2: Install a new PostgreSQL version

  1. Learn the current version of your PostgreSQL server with these commands:
    $ sudo -i -u postgres 
    $ psql -d <databaseName>
    # SHOW server_version;
    # \q
    $ su <yourLinuxUserName>
  2. With a web browser, go to the PostgreSQL download web page and select:
    • a newer PostgreSQL version
    • your RedHat Enterprise Linux version
    • your architecture: x86_64 or ppc64le
    The web page will generate and display precise download and install commands for you to copy.
  3. Copy the commands from the web page and execute them at your authority server's operating system. For example:
    $ sudo yum install
    $ sudo yum install postgresql96
    $ sudo yum install postgresql96-server
    $ sudo yum install postgresql96-contrib
    $ sudo /usr/pgsql-96/bin/postgresql-96-setup initdb

Step 3: Duplicate existing PostgreSQL configuration

  1. Whatever custom configuration was made at the old PostgreSQL version, you need to duplicate it in the new version. Two files in particular have configuration data:
    • In /var/lib/pgsql/9.5/data/postgresql.conf, look for
      • listen_address
      • max_connections.
    • In /var/lib/pgsql/9.5/data/pg_hba.conf, look for
      • host.
      listen_addresses = 'localhost,,<serverIPaddress>'
      max_connections = ...
      host <databaseName> <databaseUser> <serverIPaddress>/32 password
    Do not simply overwrite the new config files with the old ones
    New configuration files may include parameters that the old files do not. Overwriting the new files with your old ones will deprive the new server of those new parameters. Instead, compare the old and new configuration files, and edit the new files to duplicate the old custom values.
  2. Verify configuration with the commands shown in the example below.
    The PostgreSQL upgrade script provides a --check parameter that will test for errors. If that command returns *Clusters are compatible* your environment is ready to upgrade.
    $ sudo service postgresql-9.5 stop
    $ sudo -i -u postgres
    $ /usr/pgsql-9.6/bin/pg_upgrade
      --old-bindir=/usr/pgsql-9.5/bin/ --new-bindir=/usr/pgsql-9.6/bin/
      --old-datadir=/var/lib/pgsql/9.5/data/ --new-datadir=/var/lib/pgsql/9.6/data/
    *Clusters are compatible*

Step 4: Upgrade, start, verify PostgreSQL

  1. Upgrade your PostgreSQL server with the command below.
    Use the same command as in the previous step, without the --check parameter.
    $ /usr/pgsql-9.6/bin/pg_upgrade
      --old-bindir=/usr/pgsql-9.5/bin/ --new-bindir=/usr/pgsql-9.6/bin/
      --old-datadir=/var/lib/pgsql/9.5/data/ --new-datadir=/var/lib/pgsql/9.6/data/
    $ su <yourLinuxUserName>  

    The upgrade command should return this message:

    Upgrade Complete
    Optimizer statistics are not transferred by pg_upgrade so,
    once you start the new server, consider running:
    Running this script will delete the old cluster's data files:
  2. Start the new PostgreSQL server with commands like the following:
    $ sudo systemctl enable postgresql-9.6
      Created symlink from
    $ sudo systemctl start postgresql-9.6
    $ sudo systemctl status postgresql-9.6
  3. Verify that the new PostgreSQL server is running. Use commands like these:
    $ sudo -i -u postgres
    $ /var/lib/pgsql/
    $ psql -d <databaseName>
    # SHOW server_version;
    # \q
    $ su <yourLinuxUserName>

Step 5. Restart and verify your authority server

If your Code42 authority server fails to start or work with the new database, seek help from your Code42 Customer Success Manager (CSM),

  1. Restart your Code42 authority server with this command:
    sudo /etc/init.d/proserver start
  2. Sign in to your administration console.
  3. Click on the Code42 logo in the upper-left.
  4. In console's command line, issue this command:
    db.server status
    The reply should read:
    Your server is configured for PostgreSQL
  5. In the administration console, select Administration > Organizations > Active.
    If the list does not show all of your active organizations, seek help from your Code42 Customer Success Manager (CSM) at
  6. Click on one of the organization names.
    The organization details display. If the details do not accurately describe the organization, seek help from your Code42 Customer Success Manager (CSM),

Step 6. Verify your database monitoring and backup

The programs you use to monitor and back up your database are outside the scope of this article or Code42 support.

Verify that those monitoring and back up programs continue to operate on the new database without error.

Step 7: Clean up

When you are confident of the new PostgreSQL server, you can delete the old database. The following command removes the directory /var/lib/pgsql/9.5/data.

$ sudo /var/lib/pgsql/
  • Was this article helpful?