We discussed logical backups and the purpose of pg_dumpall in Chapter 3, Backup and Recovery. pg_dumpall is the only utility that can perform a logical backup of the whole cluster. This backup includes globals (such as users or tablespaces) and databases. The same pg_dumpall can be used to dump the whole cluster from an older version and restore it into PostgreSQL 13. In this recipe, we shall discuss the steps involved in performing an upgrade from PostgreSQL 9.3 to PostgreSQL 13 using pg_dumpall.
Getting ready
In order to perform a logical backup of a cluster, we need to have sufficient space on the server. If the upgrade is being performed within the same server, then we need to make sure that we have at least three times the space of the existing database cluster (excluding the space required by WAL segments and log files).
As an example, if we have a PostgreSQL 9.3 cluster with a size of 100 GB, we should have the following:
...