VPS Snaps

How to apply the November 2026 PostgreSQL update (18.7, 17.12, 16.16, 15.20) in Docker and reindex

On November 12, 2026 the PostgreSQL project shipped 18.7, 17.12, 16.16, 15.20 and 14.25. It is a normal minor update, so in Docker you only pull a new image and restart. The catch is what comes after: the release fixes index corruption bugs, and some indexes have to be rebuilt by hand once the new binaries are running. This guide takes a dump first, updates the container, finds the affected indexes in every database and rebuilds them without blocking writes, then shows how to schedule dumps and restore one to prove it works. Commands are for the official postgres image with Docker Compose v2 on any Linux VPS.

What changed and what you have to do after updating

Minor releases keep the same data format, so you do not need pg_upgrade or a dump and reload to apply them. The release notes list these post-update steps. Most databases only need the first three.

If your database hasDo this after updatingWhy
GIN indexes (jsonb, arrays, full text search, gin_trgm_ops)Reindex themSeveral GIN bugs could make queries miss rows or return unrelated rows
pg_trgm GiST indexes (gist_trgm_ops)Reindex themPossible corruption that makes searches miss matching rows
B-tree indexes on columns declared as bpchar with no lengthReindex themDeduplication on these could make index-only scans return wrong results. char(n) columns are not affected
missing chunk number errors when reading a tableRun REINDEX TABLE on that tableFixes TOAST index entries missed after an earlier REINDEX CONCURRENTLY
Incremental backups (pg_basebackup --incremental)Take a new full backupSeveral bugs could produce corrupt incremental backups
Partitioned tables on PostgreSQL 18Check for NOT NULL NO INHERIT constraintsA partition could hold NULLs it should not

14.25 is the last PostgreSQL 14 release. If you are still on 14, apply it, then plan a major upgrade. The PostgreSQL 14 to 18 Docker Compose guide walks through it.

If you skipped earlier minor releases, their release notes may list more post-update steps. Read them before you start.

Back up before you touch the container

Take a full logical dump of every database and role with pg_dumpall. It is one file, it does not depend on the image version, and you can load it into any newer PostgreSQL. Run these from the folder that holds your compose.yaml. The examples assume the database service is called db and the superuser is postgres. Replace both if yours differ.

Terminal
mkdir -p /var/backups/pg
docker compose exec -T db pg_dumpall -U postgres \
  | gzip > /var/backups/pg/before-update-$(date +%F).sql.gz

# The file should not be tiny, and gzip should read it cleanly
ls -lh /var/backups/pg/
gunzip -t /var/backups/pg/before-update-$(date +%F).sql.gz && echo OK

Copy the file off the server before going further, for example with rclone to your own bucket. A dump that only lives on the VPS you are about to change is not a backup. If your provider supports it, take a snapshot of the server as well, so you can roll back the whole machine in one step.

Keep the same image variant. If you run postgres:18-alpine, update to postgres:18.7-alpine, not the Debian-based postgres:18.7. Alpine and Debian use different C libraries, and switching between them can change how text sorts, which leaves existing text indexes out of order.

Update the image and restart

Check the version you are on now:

Terminal
docker compose exec db psql -U postgres -Atc 'SHOW server_version;'

Look at the image: line for the database service. If it is a major tag like postgres:18 or postgres:17, pulling gets the newest minor release. If it pins a minor version like postgres:18.6, change it to the new one.

Major versionTag to use
18postgres:18.7 (or 18.7-alpine, 18.7-bookworm, 18.7-trixie)
17postgres:17.12
16postgres:16.16
15postgres:15.20

Never change the major number here, for example from postgres:17 to postgres:18. A major version cannot start on the old data directory. That needs pg_upgrade or a dump and restore. Also leave the volume mount exactly as it is: the 18 image keeps data under /var/lib/postgresql, and 17 and older under /var/lib/postgresql/data.

Terminal
docker compose pull db
docker compose up -d db

# Confirm the new version is running
docker compose exec db psql -U postgres -Atc 'SHOW server_version;'
docker compose logs --tail=20 db

Your app reconnects when the database comes back. Expect a short outage while the container restarts.

Find and rebuild the affected indexes

Indexes belong to a single database, so run this in every database on the server, not just postgres. Save the SQL below as reindex-after-update.sql next to your compose.yaml. It builds a REINDEX INDEX CONCURRENTLY statement for every GIN index, every gist_trgm_ops index and every B-tree index on an unsized bpchar column, and \gexec runs each one.

reindex-after-update.sql
-- GIN indexes and pg_trgm GiST indexes
SELECT format('REINDEX INDEX CONCURRENTLY %I.%I', schemaname, indexname)
FROM pg_indexes
WHERE indexdef LIKE '% USING gin %'
   OR indexdef LIKE '%gist_trgm_ops%'
\gexec

-- B-tree indexes on bpchar columns declared without a length
SELECT format('REINDEX INDEX CONCURRENTLY %s', i.indexrelid::regclass)
FROM pg_index i
JOIN pg_class c ON c.oid = i.indexrelid
JOIN pg_am am ON am.oid = c.relam
WHERE am.amname = 'btree'
  AND EXISTS (
    SELECT 1 FROM pg_attribute a
    WHERE a.attrelid = i.indrelid
      AND a.attnum = ANY (i.indkey)
      AND a.atttypid = 'bpchar'::regtype
      AND a.atttypmod = -1)
\gexec

Then run it against each database:

Terminal
for d in $(docker compose exec -T db psql -U postgres -Atc \
  "SELECT datname FROM pg_database WHERE datallowconn AND NOT datistemplate"); do
  echo "== $d"
  docker compose exec -T db psql -U postgres -d "$d" -X -v ON_ERROR_STOP=1 \
    < reindex-after-update.sql
done

Each rebuilt index prints REINDEX. A database with nothing to rebuild prints nothing.

CONCURRENTLY lets inserts, updates and deletes carry on while each index is rebuilt. It takes longer than a plain REINDEX, which blocks writes to the table and blocks queries that would use the index until it finishes. On a small database either is fine. On a busy one, keep CONCURRENTLY.

If a concurrent rebuild fails part way, it leaves an invalid index behind with _ccnew in its name. List invalid indexes, drop any _ccnew one with DROP INDEX, and run the rebuild for that index again:

Terminal
docker compose exec db psql -U postgres -d <database> -Atc \
  'SELECT indexrelid::regclass FROM pg_index WHERE NOT indisvalid;'

If a table shows missing chunk number errors, rebuild all of its indexes, which also rebuilds its TOAST index: REINDEX TABLE <table>;

On PostgreSQL 18 with partitioned tables, look for NOT NULL NO INHERIT constraints. Drop the ones you do not want with ALTER TABLE ... DROP CONSTRAINT, and repair the ones you want to keep with ALTER TABLE ... ALTER CONSTRAINT ... INHERIT. On 17 and older the query returns no rows.

psql
SELECT conrelid::regclass, conname
FROM pg_constraint
WHERE contype = 'n' AND connoinherit
  AND conrelid IN (SELECT oid FROM pg_class WHERE relkind = 'p');

Start a fresh full backup chain

If you use PostgreSQL 17 or 18 incremental backups, take a new full pg_basebackup (without --incremental) now, and base the next incremental backups on its manifest. Earlier incrementals may be affected by the bugs this release fixes. See incremental backups with pg_basebackup for the commands.

Logical dumps made with pg_dump or pg_dumpall are not affected by that advice, but the release also fixes cases where a dump could fail to restore, so the next section restores one to check.

Schedule nightly dumps

Add a cron entry for root (sudo crontab -e). Replace /opt/myapp with the folder that holds your compose.yaml. Cron treats % as a newline, so it has to be escaped as \%.

crontab
30 2 * * * cd /opt/myapp && docker compose exec -T db pg_dumpall -U postgres | gzip > /var/backups/pg/all-$(date +\%F).sql.gz
50 2 * * * find /var/backups/pg -name 'all-*.sql.gz' -mtime +14 -delete

That keeps two weeks on the server. Send each night's file somewhere else too, such as an S3, R2 or B2 bucket, so losing the VPS does not take the backups with it. Database backups to S3 covers the upload step.

Restore a dump to prove it works

Load the dump into a throwaway container running the same tag you just deployed, then check that your databases and tables are there. Nothing here touches your real database.

Terminal
docker run -d --name pg-restore-test -e POSTGRES_PASSWORD=test postgres:18.7
sleep 20   # let the first-start setup finish

gunzip -c /var/backups/pg/before-update-<date>.sql.gz \
  | docker exec -i pg-restore-test psql -U postgres -d postgres -X -q

docker exec pg-restore-test psql -U postgres -l
docker exec pg-restore-test psql -U postgres -d <database> -c '\dt'

docker rm -f pg-restore-test

An error saying role postgres already exists is expected, because the test container creates that role on first start. Compare a row count for one busy table against production. If they match, the backup is good.

To roll back after a bad update, the safe path is the dump: start the old tag on a new, empty volume and load the file the same way. Restoring the server snapshot you took before the update also works, but it rolls back everything on the server, not just the database.

Frequently asked questions

Do I need pg_upgrade for PostgreSQL 18.7?
No. Moving from 18.x to 18.7, or 17.x to 17.12, is a minor update. Stop the server, swap the binaries (in Docker, the image) and start it again. pg_upgrade is only for major versions, such as 17 to 18.
Do I have to reindex every index?
No. The release names GIN indexes you suspect are affected, pg_trgm GiST indexes, and B-tree indexes on unsized bpchar columns. Rebuilding all GIN indexes is the simplest safe choice, because you cannot easily tell which ones were hit.
Will REINDEX CONCURRENTLY lock my tables?
It does not block inserts, updates or deletes while it runs. It cannot run inside a transaction block, which is why the script runs each statement on its own with \gexec.
Is PostgreSQL 14 still supported?
No. 14.25 is the final release of PostgreSQL 14, and it gets no more security or bug fixes. Upgrade to a newer major version.

How this was checked

Commands, limits and prices were checked against these official pages, on November 16, 2026: