Upgrade PostgreSQL using PGTurant

PGTurant, a wrapper for PostgreSQL's pg_upgrade (formerly known as pg_migrator), upgrades data stored in older versions of pgsql data files to a later pgsql major version, without data dump and reload, which otherwise is required for upgrades to major pgsql versions.

PGTurant is a multi-version PostgreSQL database system migrator that is capable of upgrading the PostgreSQL database file system to higher versions. As all the required PostgreSQL server, client and contrib RPMs are self-contained, customers need not worry about the required dependency packages while upgrading to higher PostgreSQL versions.

Though this tool was primarily intended for use by TeamForge applications during upgrades, it can also be used for any general purpose PostgreSQL upgrades provided the following prerequisites are met.

The following table lists the supported PGSQL version for various TeamForge versions.
TeamForge version Supported PostgreSQL version
6.2 (including 6.2 Patch 1) 9.0.13
7.0 (including 7.0 Patch 1) 9.0.13
7.1 9.2.4
7.2 9.2.4
8.0 9.3.5
8.0 Patch 1 9.3.6
8.1 9.3.6
8.2 9.3.6
The following table shows the possible upgrade options.
If you are in PostgreSQL 9.0 You can upgrade to PostgreSQL 9.2 or 9.3
If you are in PostgreSQL 9.2 You can upgrade to PostgreSQL 9.3
  1. Starting TeamForge 6.2, PGTurant RPMs are distributed via CollabNet TeamForge's yum repository. Check your yum repository for PGTurant RPMs.
    1. Log on to your server as root user.
    2. Check for PGTurant package information.
      • yum clean all
      • yum info pgturant
      If you see PGTurant package information, your yum repository is fine. Otherwise, contact CollabNet Support for resolution.
  2. Install PGTurant RPM.
    • yum install pgturant -y
    PGTurant files are installed in the /opt/collabnet/pgturant/ directory.
PGTurant command line options and usage examples
Option Description
-D|--debug Use this option to enable debug mode. Enabling the debug mode displays all the back-end debug messages on the console.
-s|--srcdir Use this option to pass the PostgreSQL source database directory as a command line parameter. Suppose you want to upgrade your PostgreSQL data from v9.0 to v9.3 and that your v9.0 data directory is /var/lib/pgsql/9.0/data. Syntax for this option would be: -s /var/lib/pgsql/9.0/data.
-d|--destdir Use this option to pass the PostgreSQL destination database directory as a command line parameter. Suppose you want to upgrade your PostgreSQL data from v9.0 to v9.3. Syntax for this option would be: -d /var/lib/pgsql/9.3. By default, the destination directory is assumed as /var/lib/pgsql/<upgrade version>, where <upgrade version> is specified in -u option.
-u|--upgrade Use this option to pass the destination PostgreSQL version as a command line parameter so that the database files are upgraded to that specific PostgreSQL version supported by PGTurant.
-S|--setup Use this option to install the required setup environment for PGTurant to be able to upgrade data to the desired PostgreSQL version.
-c|--check Use this option to just check the database clusters and not change the database content. You can think of it as the dry-run mode.
-m|--migrate Use this option to do the actual migration of database system to new PostgreSQL version as specified in the -u option.
-h|--help Use this option to display PGTurant help information.
Example 1: Upgrade PostgreSQL database files from v9.0 to v9.3 - dry-run mode
  • cd /opt/collabnet/pgturant/bin
  • ./pgturant -s /var/lib/pgsql/9.0/data -d /var/lib/pgsql/9.3 -u 9.3 -c
Example 2: Upgrade PostgreSQL database files from v9.2 to v9.3 - upgrade database
  • cd /opt/collabnet/pgturant/bin
  • ./pgturant -s /var/lib/pgsql/9.2/data -d /var/lib/pgsql/9.3 -u 9.3 -m
Example 3: Upgrade PostgreSQL database files from v9.0 to v9.2 - dry-run and upgrade database
  • cd /opt/collabnet/pgturant/bin
  • ./pgturant -s /var/lib/pgsql/9.0/data -d /var/lib/pgsql/9.2 -u 9.2 -c -m