CertGrid CertGrid
Hands-on Lab·PostgreSQL

PostgreSQL Logical Backups with pg_dump

pg_dump backs up one database and not the roles that own it - the dump contains zero CREATE ROLE statements. Restoring onto a fresh server fails on every GRANT until you have also run pg_dumpall --roles-only.

Backup and Restore Guide 21 of 47 Beginner

pg_dump is consistent without locking - it uses a snapshot, so a dump of a live database reflects one moment and blocks nothing. There is no flag to remember, unlike MySQL's --single-transaction.

Every command on this page ran on db-a01.
Server NameIP AddressOSRolesCPURAMHDD
db-a01192.168.0.81Ubuntu 26.04 LTSPrimary / Source / Replica Set Member 12 Core4 GB50 GB

This guide includes

Use this before relying on a pg_dump backup. This matters because it backs up one database and not the roles that own it - so a restore onto a fresh server fails on things the dump never contained.

Before you start

  1. Record what you expect to get back

  2. Take the dump and look inside it

  3. Find what the dump does not contain

Official sources