Upgrade PostgreSQL

Because TimescaleDB is a PostgreSQL extension, you need to ensure you keep your underlying PotsgreSQL installation up to date. When you upgrade your TimescaleDB extension to a new version, always take the time to check if you need to also upgrade your PostgreSQL version. If you are running an older version of PostgreSQL, you need to upgrade it first, before you upgrade your TimescaleDB extension.

TimescaleDB supports these PostgreSQL releases. If you are not running a compatible PostgreSQL version, make sure you upgrade PostgreSQL before you upgrade TimescaleDB:

PostgreSQL 9.6PostgreSQL 10PostgreSQL 11PostgreSQL 12PostgreSQL 13PostgreSQL 14
TimescaleDB 1.7
TimescaleDB 2.0
TimescaleDB 2.1
TimescaleDB 2.2
TimescaleDB 2.3
TimescaleDB 2.4
TimescaleDB 2.5 and higher

You need to upgrade PostgreSQL and TimescaleDB in two separate steps. This is so that you can make sure each upgrade completes properly. For example, if you are running PostgreSQL 10 and TimescaleDB 1.7.5, and you want to upgrade to PostgreSQL 13 and TimescaleDB 2.2, upgrade in this order:

  1. Upgrade PostgreSQL 10 to PostgreSQL 12
  2. Upgrade TimescaleDB 1.7.5 to TimescaleDB 2.2 on PostgreSQL 12
  3. Upgrade PostgreSQL 12 to PostgreSQL 13 with TimescaleDB 2.2 installed

Plan your upgrade

You can upgrade your PostgreSQL installation in-place. This means that you do not need to dump and restore your data. However, it is still important that you plan for your upgrade ahead of time.

Before you upgrade:

  • Read the release notes for the PostgreSQL version you are upgrading to.
  • Perform a backup of your database. While PostgreSQL and TimescaleDB upgrades are performed in-place, upgrading is an intrusive operation. Always make sure you have a backup on hand, and that the backup is readable in the case of disaster.

Upgrade PostgreSQL

You can use the pg_upgrade tool to upgrade PostgreSQL in-place. This means that you do not need to dump and restore your data. Instead, pg_upgrade allows you to retain the data files of your current PostgreSQL installation while binding the new PostgreSQL binary runtime to them. This is supported for PostgreSQL 8.4 and higher.

Upgrading PostgreSQL

  1. Before you begin, determine the location of the PostgreSQL binary and your data directory on your local system.

  2. At the psql prompt, perform the upgrade:

    pg_upgrade -b <OLD_BIN_DIR> -B <NEW_BIN_DIR> -d <OLD_DATA_DIR> -D <NEW_DATA_DIR>

If you are moving data to a new physical instance of PostgreSQL, you can use the pg_dump and pg_restore tools to dump your data from the old database, and then restore it into the new, upgraded, database. For more information, see the backup and restore section.

Found an issue on this page?

Report an issue!

Keywords

Related Content