In the previous recipes, we have seen how a logical backup of a database or tables can be taken using pg_dump.
pg_dump cannot serve the purpose of taking a logical backup of all the databases in the cluster in one go. For that reason, there is the pg_dumpall utility. This can be used to dump all the databases into a single dump file.
pg_dumpall can also be used to take a backup of only globals, excluding databases. Globals in PostgreSQL are the users/roles and tablespaces.
In this recipe, we shall see the steps involved in taking a cluster dump and globals dump and then proceed to the steps that show how the dumps can be restored.
Getting ready
In order to perform the globals or the entire cluster backup using pg_dumpall, it is recommended to use a database user who has superuser privilege.
How to do it
As pg_dumpall can be used to take a backup of the entire cluster or just the globals, we shall discuss...