HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Perform Postgres Upgrade from 9.6 to 13 with minimal downtime

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresdowntimewithperformminimalfromupgrade

Problem

I am looking to upgrade our Postgres 9.6 server to Postgres 13.

I have looked into the following options:

-
pg_upgrade, if I was doing this without the --link option, this would take considerable time and also a lot of unreclaimable disk space, the databases totals 1.1TB, so to do such a task I would need double the amount of disk.

-
PG Dump and Restore - I could utilize pg_dumpall however to do 1.1TB of databases would take considerable time to backup and restore to a new server.

What is the most efficient way to ensure minimal downtime when doing upgrade from pg 9.6 to 13. I can get a new server and install PG 13 and just dump and restore as mentioned above but that would take time.

I have looked into pglogical also but not entirely sure if this will give me what I need.

Any help is much appreciated.

Solution

Use pg_upgrade --link, which will be fast regardless of the size of the database.

There is no need to VACUUM after that, you only have to ANALYZE the tables, for which you can run the script that pg_upgrade provides. The documentation for pg_upgrade shows how to use rsync to quickly upgrade a standby server along with the primary.

You can of course use logical replication as well (no need for pglogical). Apart from being more complicated, you should refrain from DDL statements while you replicate. But it can reduce the downtime still more.

Context

StackExchange Database Administrators Q#293988, answer score: 4

Revisions (0)

No revisions yet.