Upgrading Old Version of PostgreSQL on NAS Device

Product version: 10.6

Last modified: 16 March 2022

Problem

The old version of PostgreSQL database does not work with NAKIVO Backup & Replication installed on NAS devices.

Background

The older version of the PostgreSQL database must be upgraded to work with NAKIVO Backup & Replication installed on NAS devices. Note that this is only applicable to 64-bit ARM CPU-based NAS devices.

Solution

To perform the upgrade, do the following:

Note

  • The upgrade process requires the same amount of free space as the SaaS repository size, located on the NAS.

  • The provided examples are for Synology NAS.

  1. Copy the old version of PostgreSQL (postgresql-arm-x64-10.15-1.gz) to the java folder on NAS. Please contact support to get this package. Example: /volume1/@appstore/NBR/transporter/java.

  2. Extract and rename the directory into psql.old.

  3. Create a new database cluster (using the new version of initdb). Example of the command:

    mkdir /volume1/path_saas/NakivoBackup.new
    
    chown -R u_bhsvc:g_bhsvc /volume1/path_saas/NakivoBackup.new
    cd /tmp
    sudo -su u_bhsvc /volume1/@appstore/NBR/transporter/java/pgsql/bin/initdb -D /volume1/path_saas/NakivoBackup.new -U bhsvc -E UTF8 -A trust --locale=C
  4. Shut down the postmaster servicing the old cluster. Example of the command:

    cd /tmp
    
    sudo -su u_bhsvc /volume1/@appstore/NBR/transporter/java/pgsql.old/bin/pg_ctl -D /volume1/path_saas/NakivoBackup stop
  5. Shut down the postmaster servicing the newcluster. Example of the command:

    cd /tmp
    sudo -su u_bhsvc /volume1/@appstore/NBR/transporter/java/pgsql/bin/pg_ctl -D /volume1/path_saas/NakivoBackup.new stop
  6. Run pg_upgrade:

    pg_upgrade -d oldCluster/data -D newCluster/data -b oldCluster/bin -B newCluster/bin

    Example of the command:

    cd /tmp
    sudo -su u_bhsvc /volume1/@appstore/NBR/transporter/java/pgsql/bin/pg_upgrade -d /volume1/path_saas/NakivoBackup -D /volume1/path_saas/NakivoBackup.new -b /volume1/@appstore/NBR/transporter/java/pgsql.old/bin -B /volume1/@appstore/NBR/transporter/java/pgsql/bin -U bhsvc
  7. Start the new server and generate optimizer statistics. Example of the command:

    cd /tmp
    sudo -su u_bhsvc /volume1/@appstore/NBR/transporter/java/pgsql/bin/pg_ctl -D /volume1/path_saas/NakivoBackup.new -o "-p5432" start
    /volume1/@appstore/NBR/transporter/java/pgsql/bin/vacuumdb -U bhsvc --all --analyze-in-stages -p 5432
    
    sudo -su u_bhsvc /volume1/@appstore/NBR/transporter/java/pgsql/bin/pg_ctl -D /volume1/path_saas/NakivoBackup.new stop
  8. Run the following script to delete the old cluster's data files::

    ./delete_old_cluster.sh
  9. Rename new NakivoBackup into the old name:

    mv /volume1/path_saas/NakivoBackup.new /volume1/path_saas/NakivoBackup