November 17, 2026
Banner showing a database labelled 14 upgrading to a database labelled 18

Image: TeQBlogs

To upgrade PostgreSQL 14 to version 18, install PostgreSQL 18 beside your old server, create an empty new cluster with initdb, run pg_upgrade --check, then run pg_upgrade for real and start the new server. With link or clone mode the transfer itself is usually quick, but you must back up first and test the steps on a copy.

PostgreSQL 14 reached end of life on 12 November 2026 with its final release, 14.25, so it will get no more security fixes. This guide follows the official pg_upgrade documentation.

Quick summary

  • Why now: PostgreSQL 14 is end of life; 14.25 is its last update.
  • Best target: PostgreSQL 18 (current minor 18.7), supported until 14 November 2030.
  • Tool: pg_upgrade, which supports upgrades from 9.2 and later.
  • Time: link, clone or swap mode is fast; the default copy mode takes longer and needs double the disk space.
  • Golden rule: full backup first, and always run --check before the real upgrade.

Why you should upgrade PostgreSQL 14 now

PostgreSQL supports each major version for five years. Version 14 first shipped on 30 September 2021, and its final minor release came out with the big PostgreSQL security update that fixed 52 flaws. Any vulnerability found after that stays unpatched on 14.

Also read: How to Migrate a Custom GPT to a ChatGPT Plugin Before 11 December

Video: Pexels
Target versionCurrent minorSupported untilGood for
PostgreSQL 1818.714 November 2030Longest support of the released versions
PostgreSQL 1717.128 November 2029Teams that want a version with more time in production
PostgreSQL 1616.169 November 2028Apps certified only up to 16
PostgreSQL 1515.2011 November 2027Short stopgap only
PostgreSQL 19RC 2Planned GA 19 November 2026Testing for now, not production
Support dates from the official PostgreSQL versioning policy.

What you need before you start

  • A full, tested backup of the PostgreSQL 14 cluster.
  • PostgreSQL 14 updated to 14.25, the final minor release.
  • PostgreSQL 18 binaries installed in their own directory (from the PostgreSQL download page or your distribution’s packages).
  • The PostgreSQL 18 builds of every extension you use (for example pgcrypto or PostGIS).
  • Enough free disk space: about the size of the data directory for copy mode, much less for link, clone or swap mode.
  • A maintenance window, because both servers must be stopped during the upgrade.

How to upgrade PostgreSQL 14 to 18: step by step

The commands below use typical Debian and Ubuntu package paths as an example. Replace the bin and data directories with the ones on your server.

Six steps to upgrade PostgreSQL 14 to 18 with pg_upgrade
Image: TeQBlogs
  1. Back up: take a full backup and confirm you can restore it.
  2. Install PostgreSQL 18: install the server package and the matching extension packages. Do not run CREATE EXTENSION in the new cluster; pg_upgrade copies the schema across.
  3. Create the new cluster: run initdb for version 18 with settings compatible with the old cluster (such as encoding and locale). Do not start it.
  4. Copy custom files: copy any custom full-text search dictionaries, synonym or stop-word files to the new installation.
  5. Set up access: pg_upgrade connects many times, so use peer authentication in pg_hba.conf or a ~/.pgpass file.
  6. Stop both servers: stop PostgreSQL 14 (and make sure the new cluster is not running).
  7. Run the check: as the postgres user, run
    pg_upgrade -b /usr/lib/postgresql/14/bin -B /usr/lib/postgresql/18/bin -d /var/lib/postgresql/14/main -D /var/lib/postgresql/18/main --link --jobs=4 --check
    Fix every problem it reports and run it again until it passes.
  8. Run the upgrade: repeat the same command without --check.
  9. Restore settings: copy back your pg_hba.conf rules and tune postgresql.conf for the new server.
  10. Start PostgreSQL 18 and connect your application to a test database first.
  11. Run the generated scripts: if pg_upgrade created SQL scripts, run them with psql --username=postgres --file=script.sql postgres.
  12. Refresh statistics: run vacuumdb --all --analyze-in-stages --missing-stats-only and then vacuumdb --all --analyze-only.
  13. Clean up: once you are happy, delete the old cluster with the script pg_upgrade leaves behind.

PostgreSQL 18’s pg_upgrade carries over most optimizer statistics, but not extended statistics made with CREATE STATISTICS, so step 12 still matters. Add --jobs to vacuumdb to speed it up on servers with several CPU cores.

Copy, link, clone or swap: which mode to use

The transfer mode decides how fast the upgrade is and whether you can fall back to PostgreSQL 14 afterwards.

Comparison of pg_upgrade copy, link, clone and swap modes
Image: TeQBlogs
ModeSpeedDisk spaceCan you go back to 14?
--copy (default)SlowestDoublesYes, old cluster untouched
--linkVery fastLittle extraOnly until the new server is started
--cloneVery fastLittle extraYes; needs Btrfs or XFS with reflink on Linux, or APFS on macOS
--swapCan be fastest with many tablesLittle extraNo, once file transfer starts; restore from backup
Based on the official pg_upgrade documentation for PostgreSQL 18.

Link, clone and swap need the old and new data directories on the same file system. If your backup is solid and downtime matters, link mode is the common choice; if you want an easy way back, use copy or clone.

If pg_upgrade fails or the check reports errors

  • Missing extension library: install the PostgreSQL 18 build of that extension and rerun the check.
  • Unsupported data types: columns using regcollation, regconfig, regdictionary, regnamespace, regoper, regoperator, regproc or regprocedure block the upgrade and must be changed first.
  • Connection or password errors: switch to peer authentication or a .pgpass file for the upgrade.
  • Need to roll back: if you used copy mode, or link mode without starting the new server, you can restart PostgreSQL 14. After link mode with the new server started, or after swap mode, restore from backup.
  • Replicas and logical replication: standbys and logical replication setups have extra steps in the documentation; the simplest route is often to rebuild standbys after the upgrade.

Small databases can also move with pg_dump and pg_restore. If you go that way, use the newly patched client tools and never restore a dump file from an untrusted source. For broader server hygiene, see our guides on updating PHP safely and patching OpenSSH on servers. Businesses without in-house database skills can ask an IT managed services partner to run the upgrade in a planned window.

Frequently asked questions

Can I upgrade PostgreSQL 14 directly to 18?

Yes. pg_upgrade supports upgrades from version 9.2 and later straight to the current major release, so you do not need to stop at 15, 16 or 17.

How long does pg_upgrade take?

It depends on database size and mode. Copy mode copies every data file, while link, clone and swap modes avoid most copying and usually finish much faster.

Does pg_upgrade keep my users, passwords and data?

Yes. It moves all databases, roles and data into the new cluster. You still need to restore your own pg_hba.conf rules and server settings.

Should I wait for PostgreSQL 19?

PostgreSQL 19 is only planned for general availability on 19 November 2026. If you are on 14 today, moving to 18 now removes the end-of-life risk, and 18 is supported until November 2030.

Bottom line

PostgreSQL 14 is out of support, and pg_upgrade makes the jump to 18 a short, well-documented job. Back up, run --check until it is clean, pick the right transfer mode, then refresh statistics and test your app before deleting the old cluster.

Sources

(Visited 1 times, 1 visits today)

About The Author

Leave a Reply

Your email address will not be published. Required fields are marked *