<!--
doc/src/sgml/ref/pg_dumpall.sgml
PostgreSQL documentation
-->
<refentry id="app-pg-dumpall">
<indexterm zone="app-pg-dumpall">
<primary>pg_dumpall</primary>
</indexterm>
<refmeta>
<refentrytitle><application>pg_dumpall</application></refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo>Application</refmiscinfo>
</refmeta>
<refnamediv>
<refname>pg_dumpall</refname>
<refpurpose>extract a <productname>PostgreSQL</productname> database cluster using a specified dump format</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>pg_dumpall</command>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<arg rep="repeat"><replaceable>option</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 id="app-pg-dumpall-description">
<title>Description</title>
<para>
<application>pg_dumpall</application> is a utility for writing out
(<quote>dumping</quote>) all <productname>PostgreSQL</productname> databases
of a cluster into an archive. The archive contains
<acronym>SQL</acronym> commands that can be used as input to <xref
linkend="app-psql"/> to restore the databases. It does this by
calling <xref linkend="app-pgdump"/> for each database in the cluster.
<application>pg_dumpall</application> also dumps global objects
that are common to all databases, namely database roles, tablespaces,
and privilege grants for configuration parameters.
(<application>pg_dump</application> does not save these objects.)
</para>
<para>
Since <application>pg_dumpall</application> reads tables from all
databases you will most likely have to connect as a database
superuser in order to produce a complete dump. Also you will need
superuser privileges to execute the saved script in order to be
allowed to add roles and create databases.
</para>
<para>
Plain text SQL scripts will be written to the standard output. Use the
<option>-f</option>/<option>--file</option> option or shell operators to
redirect it into a file.
</para>
<para>
Archives in other formats will be placed in a directory named using the
<option>-f</option>/<option>--file</option>, which is required in this case.
</para>
<para>
<application>pg_dumpall</application> needs to connect several
times to the <productname>PostgreSQL</productname> server (once per
database). If you use password authentication it will ask for
a password each time. It is convenient to have a
<filename>~/.pgpass</filename> file in such cases. See <xref
linkend="libpq-pgpass"/> for more information.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>
The following command-line options control the content and
format of the output.
<variablelist>
<varlistentry>
<term><option>-a</option></term>
<term><option>--data-only</option></term>
<listitem>
<para>
Dump only the data, not the schema (data definitions) or statistics.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-c</option></term>
<term><option>--clean</option></term>
<listitem>
<para>
Emit SQL commands to <command>DROP</command> all the dumped
databases, roles, and tablespaces before recreating them.
This option is useful when the restore is to overwrite an existing
cluster. If any of the objects do not exist in the destination
cluster, ignorable error messages will be reported during
restore, unless <option>--if-exists</option> is also specified.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-E <replaceable class="parameter">encoding</replaceable></option></term>
<term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term>
<listitem>
<para>
Create the dump in the specified character set encoding. By default,