pg_dumpall -U postgres > all.sql

Category: Databases & SQL

pg_dumpall -U postgres > all.sql

Dump all databases and cluster globals

pg_dumpall produces one SQL script containing every database plus cluster-wide objects: roles, tablespaces, and global settings. Use it for full-cluster backups or before pg_dropcluster. Restore by piping into psql as a superuser.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.