pg_dumpall

Name

pg_dumpall  --  Exports all databases on the system to a script file.

Synopsis

pg_dumpall
pg_dumpall [ -h host ] [ -p port ] [ -a ] [ -d ] [ -D ] [ -O ] [ -s ] [ -u ] [ -v ] [ -x ]
  

Parameters

-a

Pass this parameter to suppress the dumping of schema information, and only dump data.

-d

Pass this parameter to dump data using INSERT commands, instead of using COPY.

NoteWarning
 

Using this parameter will slow down the restoration process considerably.

-D

Pass this parameter to dump data using INSERT commands and include column names.

NoteWarning
 

Using this parameter will slow down the restoration process considerably.

-n

Pass this parameter to suppress the display of double quotes around identifiers during the dump. This option may cause difficulties if pg_dump encounters identifiers that have been named the same as reserved words.

-o

Pass this parameter to instruct pg_dump to dump object identifiers.

-s

Pass this parameter to suppress the dumping of data, and only dump schema information.

-u

Pass this parameter to instruct pg_dump to prompt for a username and password before starting the dump.

-v

Pass this parameter to view verbose information during the dump.

-x

Pass this parameter to suppress the dumping of ACLs and table ownership information.

-h host

Use this parameter to specify the hostname of the server that postmaster is running on. By default, pg_dump will look on the local machine and attempt to connect through domain sockets, rather than a TCP/IP connection.

-p port

If postmaster is not listening on the default socket file (or TCP/IP port), you may use this parameter to specify the socket file (or port) it is listening on. By default, it should be running on port 5432. If you have the PGPORT set, it will listen on whatever port is assigned to that variable.

-u

Use this parameter to instruct pg_dump to prompt for a database username and password before allowing the user to perform a dump.

Results

If successful, pg_dumpall will export all specified information from the database to either standard output or a file within the filesystem. If this process is unsuccessful, you will receive one of a few standard errors.

> connectDBStart() -- connect() failed: No such file or directory. Is the postmaster running locally and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?

This error message is displayed if pg_dump was not able to connect to the postmaster process on either the localhost or the hostname and port you specified. Make sure postmaster is running on the host you are trying to connect to; and if it is running, make sure that you have given the correct port number to connect to.

Connection to database 'database_name' failed. FATAL 1: SetUserId: user 'username' is not in 'pg_shadow'

The username you specified is not entered in the pg_shadow system relation (i.e., your username is not recognized by this database). Make sure you are using the correct username; if you are, you may have to try a different username or recreate your account within the database.

dumpSequence(table): SELECT failed

This error message is displayed if your database account does not have the correct permissions to view table information (if this is the case, you will also get an error message if you try to SELECT from the database).

Note

The pg_dump program executes SELECT statements to retrieve data from the database; if you do not have permissions to SELECT data, you will encounter errors using program.

Description

Use pg_dumpall to export all PostgreSQL databases into one file. Information (data and/or schema information) is saved in this file in a script format that can later be read by PostgreSQL and used to reconstruct databases with the saved information. In addition to database information, this command also exports the globally accessible pg_shadow table and the commands neccessary to to create each dumped database.

pg_dumpall takes all pg_dump options, but -f, -t and dbname should be omitted.

Note

Because this program is essentially multiple calls of pg_dump , the pg_dump entry can provide more information about its workings.

Examples

The following example demonstrates how to dump all databases.

% pg_dumpall > backupdb

The next example reloads the databases.

% psql -f backupdb template1