Extracts all databases in a HAWQ system to a single script file or other archive file.
pg_dumpall [<options>] ...
<general options> = [-f | --filespaces] [-i | --ignore-version ] [--help ] [--version] <options controlling output content> = [-a --dataonly ] [-c | --clean ] [-d | --inserts] [-D | --column_inserts] [-F | --filespaces ] [-g | --globals-only] [-o | --oids ] [-d | --inserts] [-O | --no-owner] [-r | --resource-queues] [-s | --schema-only] [-S <username> | --superuser=<username> ] [-v | --verbose ] [-x | --no-privileges ] [--disable-dollar-quoting] [--disable-triggers] [--use-set-session-authorization] [--gp-syntax] [--no-gp-syntax] <connection_options> = [-h <host> | --host <host>] [-p <port> | -- port <port>] [-U <username> | --username <username>] [-w | --no-password] [-W | --password]
pg_dumpall is a standard PostgreSQL utility for backing up all databases in a HAWQ (or PostgreSQL) instance, and is also supported in HAWQ. It creates a single (non-parallel) dump file.
pg_dumpall creates a single script file that contains SQL commands that can be used as input to psql to restore the databases. It does this by calling pg_dump for each database.
pg_dumpall also dumps global objects that are common to all databases. (
pg_dump does not save these objects.) This currently includes information about database users and groups, and access permissions that apply to databases as a whole.
pg_dumpall reads tables from all databases, connect as a database superuser to assure producing a complete dump, as well as to execute the saved script, add users and groups, and to create databases.
The SQL script will be written to the standard output. Shell operators should be used to redirect it into a file.
pg_dumpall needs to connect to the HAWQ master server several times (once per database). If you use password authentication, a password could be requested for each connection, so using a
~/.pgpass file is recommended.
pg_dumpcan dump from servers running previous releases of HAWQ (or PostgreSQL), but some older versions may not be supported. Use this option if you need to override the version check.
Output Control Options
INSERTcommands (rather than
COPY). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-PostgreSQL-based databases. Also, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents. Note that the restore may fail altogether if you have rearranged column order. The
-Doption is safe against column order changes, though even slower.
INSERTcommands with explicit column names
(INSERT INTO table (column, ...) VALUES ...). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-PostgreSQL-based databases. Also, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents.
SET SESSION AUTHORIZATIONstatements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify
-O. This option is only meaningful for the plain-text format. For the archive formats, you may specify the option when you call pg_restore.
--disable-triggersis used. Starting the resulting script as a superuser is preferred.
Note: HAWQ does not support user-defined triggers.
pg_dumpallto include commands to temporarily disable triggers on the target tables while the data is reloaded. Use this if you do not want to invoke triggers on the tables during data reload. You need superuser permissions to perform commands issued for
--disable-triggers. Either specify a superuser name with the
-Soption, or start the resulting script as a superuser.
Note: HAWQ does not support user-defined triggers.
SET SESSION AUTHORIZATIONcommands instead of
ALTER OWNERcommands to determine object ownership. This makes the dump more standards compatible, but depending on the history of the objects in the dump, may not restore properly. A dump using
SET SESSION AUTHORIZATIONwill require superuser privileges to restore correctly, whereas
ALTER OWNERrequires lesser privileges.
CREATE TABLEstatements. This allows the distribution policy (
DISTRIBUTED RANDOMLYclauses) of a HAWQ table to be dumped, which is useful for restoring into other HAWQ systems.
PGHOSTor defaults to
PGPORTor defaults to 5432.
PGUSERor defaults to the current system role name.
pg_dumpall calls pg_dump internally, some diagnostic messages will refer to
Once restored, it is wise to run
ANALYZE on each database so the query planner has useful statistics. You can also run
vacuumdb -a -z to analyze all databases.
All tablespace (filespace) directories used by
pg_dumpall must exist before the restore. Otherwise, database creation will fail for databases in non-default locations.
To dump all databases:
$ pg_dumpall > db.out
To reload this file:
$ psql template1 -f db.out
To dump only global objects (including filespaces and resource queues):
$ pg_dumpall -g -f -r