Shared development databases: a monthly patching routine
This guide covers patching a PostgreSQL database that several developers share, on a server your team runs. Installing a minor release means stopping that server, which ends every developer's session. The routine below plans around that stop with a checkpoint, a rehearsal on an isolated copy, an announced restart and a check afterward. We recommend a monthly slot for minor releases, with major upgrades on a separate date.
What this routine assumes
The routine assumes one PostgreSQL cluster that several developers share, on a server your own team patches, and a test suite that can point at any database address. It also assumes a scratch server for rehearsals that nobody else uses and that never receives traffic from the team. If the database runs on a managed service, follow the provider's upgrade documentation instead, because this routine covers a server your team patches itself.
The monthly cadence is our recommendation for development use. It works alongside the PostgreSQL release calendar. Apply an urgent security fix when it ships, without waiting for the next slot.
How a monthly slot fits the PostgreSQL release calendar
The PostgreSQL versioning policy says each supported major version gets bug fixes, and security fixes when needed, in a minor release at least once every three months. On the project's roadmap page, the target dates are the second Thursday of February, May, August and November, with November 12, 2026 scheduled as the next release after November 4, 2026. Both pages say the project can ship a release between those dates when an important bug or security fix can't wait.
Our recommended target is to have each scheduled release on your server within about a month of its release date, and a monthly slot meets that target. Treat a security release as its own trigger. The PostgreSQL security page says notices about security releases go out on the pgsql-announce mailing list, with a Security tag you can filter on, so subscribe whoever owns the database and pull the patch forward when a notice covers a version you run.
According to the versioning policy, the community considers minor upgrades less risky than staying on an old minor version, and the policy recommends always running the current minor release of your major version.
How to tell a minor release from a major one
Since PostgreSQL 10, the versioning policy puts the major version in the first number and the minor release in the second, so its example of 10.0 to 10.1 is a minor upgrade. According to the chapter Upgrading a PostgreSQL Cluster in the PostgreSQL 18 documentation, minor releases never change the internal storage format, so you replace the executables while the server is down, restart it, and the data directory stays as it was. The versioning policy adds that some minor releases need extra steps, so read the release notes first.
Major versions can change the storage format. The same chapter lists a dump and restore, pg_upgrade or logical replication as the ways across, and says to read the release notes of every major version you skip, especially the Migration section. That work gets its own date, and the monthly routine handles minor releases only.
Each month's routine, step by step
The Basis column marks which steps come from the PostgreSQL documentation and which are our recommendation.
| Step | What to do | Basis |
|---|---|---|
| Check | Run SELECT version(); on the shared server and compare it with the current minor release in the Releases table of the versioning policy | version() from the System Information Functions and Operators page, which recommends server_version_num for scripted checks; doing it monthly is our recommendation |
| Read | Go through the release notes for each minor release between your version and the current one, and list any extra steps they ask for | Versioning policy |
| Checkpoint | Dump the roles and tablespaces with pg_dumpall --globals-only, then dump each database in custom format | SQL Dump section and the pg_dump and pg_dumpall reference pages |
| Rehearse | On the isolated scratch server running the new release, restore the roles first, then restore each database with pg_restore --create and run the test suite there | Restore order from the SQL Dump section; --create from the pg_restore reference page; the rehearsal is our recommendation |
| Announce | Tell the team the restart time, that open transactions will roll back and that every connection will drop and has to reconnect | Recommendation, based on the shutdown modes in the server documentation |
| Restart | Stop the server, install the new binaries and start it again. If a package manager installs PostgreSQL, the package upgrade may stop and start the server itself, so run it at the announced time | Upgrading a PostgreSQL Cluster chapter |
| Apply | Run the extra steps you listed from the release notes on the shared server, such as ALTER EXTENSION name UPDATE in each database that uses the extension | Release notes via the versioning policy; ALTER EXTENSION reference page |
| Verify | Run SELECT version(); again, run the test suite against the shared server and note how long the window took from stop to passing tests | Recommendation |
Take a restore checkpoint and restore it on the scratch server
The SQL Dump section of the PostgreSQL documentation says a pg_dump output is an internally consistent snapshot of the database as of the moment the dump started. It doesn't block other work while it runs, apart from operations that need an exclusive lock, such as most forms of ALTER TABLE. The pg_dump reference page also says that, except in simple cases, pg_dump is generally not the right choice for regular backups of production databases, so treat this checkpoint as a development rehearsal and keep whatever backup system the server already has.
According to the SQL Dump section, pg_dump covers one database at a time and leaves out roles and tablespaces, which belong to the whole cluster, and pg_dumpall --globals-only captures them. Before a restore, every role that owns objects or holds permissions in the dump has to exist already, or the restore can't recreate the original ownership and permissions. That sets the order on the scratch server: roles and tablespaces first, then the restore. The pg_restore reference page shows pg_restore -C -d postgres, which creates the database and, according to the same page, also restores its comment, its ALTER DATABASE ... SET and ALTER ROLE ... IN DATABASE ... SET settings and its access privileges. A plain createdb followed by pg_restore -d leaves those out, so the copy can lose settings saved on the shared server. For the dump itself, the pg_dump reference page calls the custom format (-Fc) one of the two most flexible formats for pg_restore and says it is compressed by default.
The sequence below is an illustration to adapt and review, with placeholders, and it isn't ready to run against any server people depend on. SHARED_HOST is the shared server, SCRATCH_HOST is an empty scratch server already running the new release, with the same extension packages and locales installed as on the shared server so the restore doesn't stop on a missing one (recommendation), appdb stands for each database, and postgres stands for a superuser on each server, since the SQL Dump section says restoring role and tablespace definitions needs superuser access.
# Illustration only. Replace every placeholder and confirm SCRATCH_HOST before the restore lines.
# Passwords come from ~/.pgpass (chmod 0600), never from the command line.
umask 077
# On the shared server: roles and tablespaces, then one dump per database.
pg_dumpall -h SHARED_HOST -U postgres --globals-only --no-role-passwords -f globals.sql
pg_dump -h SHARED_HOST -U postgres -Fc -f appdb.dump appdb
# On the scratch server: globals first, then the restore, which creates each database.
psql -X -h SCRATCH_HOST -U postgres -f globals.sql postgres
pg_restore -h SCRATCH_HOST -U postgres --exit-on-error -C -d postgres appdb.dump
psql -X -h SCRATCH_HOST -U postgres -d appdb -c 'ANALYZE'A few details in that sketch come straight from the reference pages. The pg_dumpall page says the globals script will report a harmless "role already exists" error for the bootstrap superuser, unless the scratch server was initialized with a different bootstrap superuser name, so read the output for anything beyond that one line rather than stopping on the first error. Tablespace directories have to exist before the restore, according to the same page, and the SQL Dump section says to check that the tablespace paths in the dump suit the new installation. Without --no-role-passwords, the globals file carries the shared server's role passwords. With it, the pg_dumpall page says restored roles get a null password and password logins fail until one is set, so set rehearsal passwords on the scratch server only. --exit-on-error stops pg_restore at the first SQL error, per its reference page. The password file page says that on Unix systems ~/.pgpass is ignored unless its permissions block group and world access. Keep the dump and globals files readable only by whoever runs the rehearsal, and delete them from the scratch server when it's done (recommendation).
This routine uses the restore as the rehearsal, so each month's checkpoint gets restored at least once (recommendation). The SQL Dump section also advises running ANALYZE after a restore so the query planner has statistics to work with, which the last line of the sketch does. Database restore tests on hosted SQL Server and PostgreSQL covers what a restore test should check.
Rehearse on a copy first
Point the test suite at the restored copy on the scratch server (recommendation). For major upgrades, the Upgrading chapter says cautious users test their client applications on the new version before switching over. Doing the same for a minor release (recommendation) takes a restore and a test run on the scratch server, and any failure shows up on a copy nobody depends on. Test environment provisioning from approved configurations covers rebuilding a scratch server the same way each time.
If the release notes say an extension needs updating, the ALTER EXTENSION reference page gives the command, ALTER EXTENSION name UPDATE, and says the extension must supply an update script. Run it on the copy first, in each database that uses the extension, and then on the shared server after the restart. Check the release notes separately for repairs to existing data and indexes, and list which steps apply to the restored copy and which must run on the shared server (recommendation). Write down how long the restore took and what failed. That record tells you the checkpoint can be restored and roughly how long recovery from it would take, which is separate from how long the shared server's restart window needs to be.
An announced restart window
The PostgreSQL page on shutting down the server describes three modes. Smart mode refuses new connections and waits for existing sessions to end, while fast mode aborts every current transaction. Immediate mode skips normal shutdown, so the next start runs recovery, and the page reserves it for emergencies. According to the pg_ctl reference page, fast is the default for pg_ctl stop.
If PostgreSQL came from your distribution's packages, check what the package upgrade does. The Debian postgresql-common maintainer scripts request stops and starts during package upgrades. Service policy and each cluster's startup configuration affect whether those requests run. Check those settings on Debian and Ubuntu, then run the package upgrade in the announced window because it can restart the server (recommendation). Keep automatic package updates from installing the server package outside the slot (recommendation). The Debian pg_ctlcluster manual page says it also stops in fast mode by default.
A smart shutdown waits as long as any session stays connected, including an idle one left open in someone's database client. On a shared server, a fast shutdown at an announced time is the practical choice (recommendation). Send the notice a day ahead, say open transactions will roll back and every connection will drop, and name who to contact about a long job.
Size the window from the restart itself, meaning the stop, the binary install, the start and the checks afterward, since a minor update leaves the data directory in place and involves no restore. Time those steps each month and use the record to set next month's window (recommendation). After the restart, run SELECT version(); and confirm the new minor release, then run the test suite against the shared server and post the result where the notice went (recommendation).
Major upgrades on their own date
The versioning policy supports each major version for five years after its first release, then ships a final minor release, after which that version is unsupported. Its Releases table lists each final release date, with PostgreSQL 14 scheduled to reach its final release on November 12, 2026, eight days after November 4, 2026. Check it each month and schedule the major upgrade well ahead of your version's date (recommendation).
The pg_upgrade reference page says pg_upgrade --check runs only the compatibility checks, can run while the old server is still up, and outlines any manual adjustments the upgrade needs. Choose the transfer mode with rollback in mind. After a link mode upgrade starts the new cluster, the page says the old one has to be restored from backup, while clone mode, where the file system supports it, keeps the old cluster usable.
Take a fresh backup right before the upgrade instead of leaning on the last monthly checkpoint (recommendation). The Upgrading chapter says to make sure the database isn't being updated while that backup runs, because changes made during it won't be included, and, if necessary, editing pg_hba.conf so only you can connect. Rolling back to that backup returns the database to the moment it was taken, so anything written on the new version after the switch is gone unless you copy it across yourself. What a passing test proves in dev, QA and staging explains what a clean run on development tells you about later stages.