1<!--
2doc/src/sgml/ref/pg_dumpall.sgml
3PostgreSQL documentation
4-->
5
6<refentry id="app-pg-dumpall">
7 <indexterm zone="app-pg-dumpall">
8  <primary>pg_dumpall</primary>
9 </indexterm>
10
11 <refmeta>
12  <refentrytitle><application>pg_dumpall</application></refentrytitle>
13  <manvolnum>1</manvolnum>
14  <refmiscinfo>Application</refmiscinfo>
15 </refmeta>
16
17 <refnamediv>
18  <refname>pg_dumpall</refname>
19  <refpurpose>extract a <productname>PostgreSQL</productname> database cluster into a script file</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23  <cmdsynopsis>
24   <command>pg_dumpall</command>
25   <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
26   <arg rep="repeat"><replaceable>option</replaceable></arg>
27  </cmdsynopsis>
28 </refsynopsisdiv>
29
30 <refsect1 id="app-pg-dumpall-description">
31  <title>Description</title>
32
33  <para>
34   <application>pg_dumpall</application> is a utility for writing out
35   (<quote>dumping</quote>) all <productname>PostgreSQL</productname> databases
36   of a cluster into one script file.  The script file contains
37   <acronym>SQL</acronym> commands that can be used as input to <xref
38   linkend="app-psql"/> to restore the databases.  It does this by
39   calling <xref linkend="app-pgdump"/> for each database in the cluster.
40   <application>pg_dumpall</application> also dumps global objects
41   that are common to all databases, that is, database roles and tablespaces.
42   (<application>pg_dump</application> does not save these objects.)
43  </para>
44
45  <para>
46   Since <application>pg_dumpall</application> reads tables from all
47   databases you will most likely have to connect as a database
48   superuser in order to produce a complete dump.  Also you will need
49   superuser privileges to execute the saved script in order to be
50   allowed to add roles and create databases.
51  </para>
52
53  <para>
54   The SQL script will be written to the standard output.  Use the
55   <option>-f</option>/<option>--file</option> option or shell operators to
56   redirect it into a file.
57  </para>
58
59  <para>
60  <application>pg_dumpall</application> needs to connect several
61  times to the <productname>PostgreSQL</productname> server (once per
62  database).  If you use password authentication it will ask for
63  a password each time. It is convenient to have a
64  <filename>~/.pgpass</filename> file in such cases. See <xref
65  linkend="libpq-pgpass"/> for more information.
66  </para>
67
68 </refsect1>
69
70 <refsect1>
71  <title>Options</title>
72
73   <para>
74    The following command-line options control the content and
75    format of the output.
76
77    <variablelist>
78     <varlistentry>
79      <term><option>-a</option></term>
80      <term><option>--data-only</option></term>
81      <listitem>
82       <para>
83        Dump only the data, not the schema (data definitions).
84       </para>
85      </listitem>
86     </varlistentry>
87
88     <varlistentry>
89      <term><option>-c</option></term>
90      <term><option>--clean</option></term>
91      <listitem>
92       <para>
93        Include SQL commands to clean (drop) databases before
94        recreating them.  <command>DROP</command> commands for roles and
95        tablespaces are added as well.
96       </para>
97      </listitem>
98     </varlistentry>
99
100     <varlistentry>
101      <term><option>-E <replaceable class="parameter">encoding</replaceable></option></term>
102      <term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term>
103      <listitem>
104       <para>
105        Create the dump in the specified character set encoding. By default,
106        the dump is created in the database encoding.  (Another way to get the
107        same result is to set the <envar>PGCLIENTENCODING</envar> environment
108        variable to the desired dump encoding.)
109       </para>
110      </listitem>
111     </varlistentry>
112
113     <varlistentry>
114      <term><option>-f <replaceable class="parameter">filename</replaceable></option></term>
115      <term><option>--file=<replaceable class="parameter">filename</replaceable></option></term>
116      <listitem>
117       <para>
118        Send output to the specified file.  If this is omitted, the
119        standard output is used.
120       </para>
121      </listitem>
122     </varlistentry>
123
124     <varlistentry>
125      <term><option>-g</option></term>
126      <term><option>--globals-only</option></term>
127      <listitem>
128       <para>
129        Dump only global objects (roles and tablespaces), no databases.
130       </para>
131      </listitem>
132     </varlistentry>
133
134     <varlistentry>
135      <term><option>-O</option></term>
136      <term><option>--no-owner</option></term>
137      <listitem>
138       <para>
139        Do not output commands to set
140        ownership of objects to match the original database.
141        By default, <application>pg_dumpall</application> issues
142        <command>ALTER OWNER</command> or
143        <command>SET SESSION AUTHORIZATION</command>
144        statements to set ownership of created schema elements.
145        These statements
146        will fail when the script is run unless it is started by a superuser
147        (or the same user that owns all of the objects in the script).
148        To make a script that can be restored by any user, but will give
149        that user ownership of all the objects, specify <option>-O</option>.
150       </para>
151      </listitem>
152     </varlistentry>
153
154     <varlistentry>
155      <term><option>-r</option></term>
156      <term><option>--roles-only</option></term>
157      <listitem>
158       <para>
159        Dump only roles, no databases or tablespaces.
160       </para>
161      </listitem>
162     </varlistentry>
163
164     <varlistentry>
165      <term><option>-s</option></term>
166      <term><option>--schema-only</option></term>
167      <listitem>
168       <para>
169        Dump only the object definitions (schema), not data.
170       </para>
171      </listitem>
172     </varlistentry>
173
174     <varlistentry>
175      <term><option>-S <replaceable class="parameter">username</replaceable></option></term>
176      <term><option>--superuser=<replaceable class="parameter">username</replaceable></option></term>
177      <listitem>
178       <para>
179        Specify the superuser user name to use when disabling triggers.
180        This is relevant only if <option>--disable-triggers</option> is used.
181        (Usually, it's better to leave this out, and instead start the
182        resulting script as superuser.)
183       </para>
184      </listitem>
185     </varlistentry>
186
187     <varlistentry>
188      <term><option>-t</option></term>
189      <term><option>--tablespaces-only</option></term>
190      <listitem>
191       <para>
192        Dump only tablespaces, no databases or roles.
193       </para>
194      </listitem>
195     </varlistentry>
196
197     <varlistentry>
198      <term><option>-v</option></term>
199      <term><option>--verbose</option></term>
200      <listitem>
201       <para>
202        Specifies verbose mode.  This will cause
203        <application>pg_dumpall</application> to output start/stop
204        times to the dump file, and progress messages to standard error.
205        It will also enable verbose output in <application>pg_dump</application>.
206       </para>
207      </listitem>
208     </varlistentry>
209
210     <varlistentry>
211       <term><option>-V</option></term>
212       <term><option>--version</option></term>
213       <listitem>
214       <para>
215       Print the <application>pg_dumpall</application> version and exit.
216       </para>
217       </listitem>
218     </varlistentry>
219
220     <varlistentry>
221      <term><option>-x</option></term>
222      <term><option>--no-privileges</option></term>
223      <term><option>--no-acl</option></term>
224      <listitem>
225       <para>
226        Prevent dumping of access privileges (grant/revoke commands).
227       </para>
228      </listitem>
229     </varlistentry>
230
231     <varlistentry>
232      <term><option>--binary-upgrade</option></term>
233      <listitem>
234       <para>
235        This option is for use by in-place upgrade utilities.  Its use
236        for other purposes is not recommended or supported.  The
237        behavior of the option may change in future releases without
238        notice.
239       </para>
240      </listitem>
241     </varlistentry>
242
243     <varlistentry>
244      <term><option>--column-inserts</option></term>
245      <term><option>--attribute-inserts</option></term>
246      <listitem>
247       <para>
248        Dump data as <command>INSERT</command> commands with explicit
249        column names (<literal>INSERT INTO
250        <replaceable>table</replaceable>
251        (<replaceable>column</replaceable>, ...) VALUES
252        ...</literal>).  This will make restoration very slow; it is mainly
253        useful for making dumps that can be loaded into
254        non-<productname>PostgreSQL</productname> databases.
255       </para>
256      </listitem>
257     </varlistentry>
258
259     <varlistentry>
260      <term><option>--disable-dollar-quoting</option></term>
261      <listitem>
262       <para>
263        This option disables the use of dollar quoting for function bodies,
264        and forces them to be quoted using SQL standard string syntax.
265       </para>
266     </listitem>
267    </varlistentry>
268
269     <varlistentry>
270      <term><option>--disable-triggers</option></term>
271      <listitem>
272       <para>
273        This option is relevant only when creating a data-only dump.
274        It instructs <application>pg_dumpall</application> to include commands
275        to temporarily disable triggers on the target tables while
276        the data is reloaded.  Use this if you have referential
277        integrity checks or other triggers on the tables that you
278        do not want to invoke during data reload.
279       </para>
280
281       <para>
282        Presently, the commands emitted for <option>--disable-triggers</option>
283        must be done as superuser.  So, you should also specify
284        a superuser name with <option>-S</option>, or preferably be careful to
285        start the resulting script as a superuser.
286       </para>
287      </listitem>
288     </varlistentry>
289
290     <varlistentry>
291      <term><option>--exclude-database=<replaceable class="parameter">pattern</replaceable></option></term>
292      <listitem>
293       <para>
294        Do not dump databases whose name matches
295        <replaceable class="parameter">pattern</replaceable>.
296        Multiple patterns can be excluded by writing multiple
297        <option>--exclude-database</option> switches.  The
298        <replaceable class="parameter">pattern</replaceable> parameter is
299        interpreted as a pattern according to the same rules used by
300        <application>psql</application>'s <literal>\d</literal>
301        commands (see <xref linkend="app-psql-patterns"/> below),
302        so multiple databases can also be excluded by writing wildcard
303        characters in the pattern.  When using wildcards, be careful to
304        quote the pattern if needed to prevent shell wildcard expansion.
305       </para>
306      </listitem>
307     </varlistentry>
308
309     <varlistentry>
310      <term><option>--extra-float-digits=<replaceable class="parameter">ndigits</replaceable></option></term>
311      <listitem>
312       <para>
313        Use the specified value of extra_float_digits when dumping
314        floating-point data, instead of the maximum available precision.
315        Routine dumps made for backup purposes should not use this option.
316       </para>
317      </listitem>
318     </varlistentry>
319
320     <varlistentry>
321      <term><option>--if-exists</option></term>
322      <listitem>
323       <para>
324        Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
325        clause) to drop databases and other objects.  This option is not valid
326        unless <option>--clean</option> is also specified.
327       </para>
328      </listitem>
329     </varlistentry>
330
331     <varlistentry>
332      <term><option>--inserts</option></term>
333      <listitem>
334       <para>
335        Dump data as <command>INSERT</command> commands (rather
336        than <command>COPY</command>).  This will make restoration very slow;
337        it is mainly useful for making dumps that can be loaded into
338        non-<productname>PostgreSQL</productname> databases.  Note that
339        the restore might fail altogether if you have rearranged column order.
340        The <option>--column-inserts</option> option is safer, though even
341        slower.
342       </para>
343      </listitem>
344     </varlistentry>
345
346     <varlistentry>
347      <term><option>--load-via-partition-root</option></term>
348      <listitem>
349       <para>
350        When dumping data for a table partition, make
351        the <command>COPY</command> or <command>INSERT</command> statements
352        target the root of the partitioning hierarchy that contains it, rather
353        than the partition itself.  This causes the appropriate partition to
354        be re-determined for each row when the data is loaded.  This may be
355        useful when reloading data on a server where rows do not always fall
356        into the same partitions as they did on the original server.  That
357        could happen, for example, if the partitioning column is of type text
358        and the two systems have different definitions of the collation used
359        to sort the partitioning column.
360       </para>
361
362       <!-- Currently, we don't need pg_dump's warning about parallelism here,
363        since parallel restore from a pg_dumpall script is impossible.
364       -->
365      </listitem>
366     </varlistentry>
367
368     <varlistentry>
369      <term><option>--lock-wait-timeout=<replaceable class="parameter">timeout</replaceable></option></term>
370      <listitem>
371       <para>
372        Do not wait forever to acquire shared table locks at the beginning of
373        the dump. Instead, fail if unable to lock a table within the specified
374        <replaceable class="parameter">timeout</replaceable>. The timeout may be
375        specified in any of the formats accepted by <command>SET
376        statement_timeout</command>.  Allowed values vary depending on the server
377        version you are dumping from, but an integer number of milliseconds
378        is accepted by all versions since 7.3.  This option is ignored when
379        dumping from a pre-7.3 server.
380       </para>
381      </listitem>
382     </varlistentry>
383
384     <varlistentry>
385      <term><option>--no-comments</option></term>
386      <listitem>
387       <para>
388        Do not dump comments.
389       </para>
390      </listitem>
391     </varlistentry>
392
393     <varlistentry>
394      <term><option>--no-publications</option></term>
395      <listitem>
396       <para>
397        Do not dump publications.
398       </para>
399      </listitem>
400     </varlistentry>
401
402     <varlistentry>
403      <term><option>--no-role-passwords</option></term>
404      <listitem>
405       <para>
406        Do not dump passwords for roles.  When restored, roles will have a
407        null password, and password authentication will always fail until the
408        password is set.  Since password values aren't needed when this option
409        is specified, the role information is read from the catalog
410        view <structname>pg_roles</structname> instead
411        of <structname>pg_authid</structname>.  Therefore, this option also
412        helps if access to <structname>pg_authid</structname> is restricted by
413        some security policy.
414       </para>
415      </listitem>
416     </varlistentry>
417
418     <varlistentry>
419      <term><option>--no-security-labels</option></term>
420      <listitem>
421       <para>
422        Do not dump security labels.
423       </para>
424      </listitem>
425     </varlistentry>
426
427     <varlistentry>
428      <term><option>--no-subscriptions</option></term>
429      <listitem>
430       <para>
431        Do not dump subscriptions.
432       </para>
433      </listitem>
434     </varlistentry>
435
436     <varlistentry>
437      <term><option>--no-sync</option></term>
438      <listitem>
439       <para>
440        By default, <command>pg_dumpall</command> will wait for all files
441        to be written safely to disk.  This option causes
442        <command>pg_dumpall</command> to return without waiting, which is
443        faster, but means that a subsequent operating system crash can leave
444        the dump corrupt.  Generally, this option is useful for testing
445        but should not be used when dumping data from production installation.
446       </para>
447      </listitem>
448     </varlistentry>
449
450     <varlistentry>
451      <term><option>--no-tablespaces</option></term>
452      <listitem>
453       <para>
454        Do not output commands to create tablespaces nor select tablespaces
455        for objects.
456        With this option, all objects will be created in whichever
457        tablespace is the default during restore.
458       </para>
459      </listitem>
460     </varlistentry>
461
462     <varlistentry>
463      <term><option>--no-unlogged-table-data</option></term>
464      <listitem>
465       <para>
466        Do not dump the contents of unlogged tables.  This option has no
467        effect on whether or not the table definitions (schema) are dumped;
468        it only suppresses dumping the table data.
469       </para>
470      </listitem>
471     </varlistentry>
472
473     <varlistentry>
474      <term><option>--on-conflict-do-nothing</option></term>
475      <listitem>
476       <para>
477        Add <literal>ON CONFLICT DO NOTHING</literal> to
478        <command>INSERT</command> commands.
479        This option is not valid unless <option>--inserts</option> or
480        <option>--column-inserts</option> is also specified.
481       </para>
482      </listitem>
483     </varlistentry>
484
485     <varlistentry>
486      <term><option>--quote-all-identifiers</option></term>
487      <listitem>
488       <para>
489        Force quoting of all identifiers.  This option is recommended when
490        dumping a database from a server whose <productname>PostgreSQL</productname>
491        major version is different from <application>pg_dumpall</application>'s, or when
492        the output is intended to be loaded into a server of a different
493        major version.  By default, <application>pg_dumpall</application> quotes only
494        identifiers that are reserved words in its own major version.
495        This sometimes results in compatibility issues when dealing with
496        servers of other versions that may have slightly different sets
497        of reserved words.  Using <option>--quote-all-identifiers</option> prevents
498        such issues, at the price of a harder-to-read dump script.
499       </para>
500      </listitem>
501     </varlistentry>
502
503     <varlistentry>
504      <term><option>--rows-per-insert=<replaceable class="parameter">nrows</replaceable></option></term>
505      <listitem>
506       <para>
507        Dump data as <command>INSERT</command> commands (rather than
508        <command>COPY</command>).  Controls the maximum number of rows per
509        <command>INSERT</command> command. The value specified must be a
510        number greater than zero.  Any error during reloading will cause only
511        rows that are part of the problematic <command>INSERT</command> to be
512        lost, rather than the entire table contents.
513       </para>
514      </listitem>
515     </varlistentry>
516
517     <varlistentry>
518      <term><option>--use-set-session-authorization</option></term>
519      <listitem>
520       <para>
521        Output SQL-standard <command>SET SESSION AUTHORIZATION</command> commands
522        instead of <command>ALTER OWNER</command> commands to determine object
523        ownership.  This makes the dump more standards compatible, but
524        depending on the history of the objects in the dump, might not restore
525        properly.
526       </para>
527      </listitem>
528     </varlistentry>
529
530     <varlistentry>
531       <term><option>-?</option></term>
532       <term><option>--help</option></term>
533       <listitem>
534       <para>
535       Show help about <application>pg_dumpall</application> command line
536       arguments, and exit.
537       </para>
538       </listitem>
539     </varlistentry>
540
541    </variablelist>
542   </para>
543
544  <para>
545   The following command-line options control the database connection parameters.
546
547   <variablelist>
548     <varlistentry>
549      <term><option>-d <replaceable class="parameter">connstr</replaceable></option></term>
550      <term><option>--dbname=<replaceable class="parameter">connstr</replaceable></option></term>
551      <listitem>
552       <para>
553        Specifies parameters used to connect to the server, as a <link
554        linkend="libpq-connstring">connection string</link>;  these
555        will override any conflicting command line options.
556       </para>
557       <para>
558        The option is called <literal>--dbname</literal> for consistency with other
559        client applications, but because <application>pg_dumpall</application>
560        needs to connect to many databases, the database name in the
561        connection string will be ignored.  Use the <literal>-l</literal>
562        option to specify the name of the database used for the initial
563        connection, which will dump global objects and discover what other
564        databases should be dumped.
565       </para>
566      </listitem>
567     </varlistentry>
568
569     <varlistentry>
570      <term><option>-h <replaceable>host</replaceable></option></term>
571      <term><option>--host=<replaceable>host</replaceable></option></term>
572      <listitem>
573       <para>
574        Specifies the host name of the machine on which the database
575        server is running.  If the value begins with a slash, it is
576        used as the directory for the Unix domain socket.  The default
577        is taken from the <envar>PGHOST</envar> environment variable,
578        if set, else a Unix domain socket connection is attempted.
579       </para>
580      </listitem>
581     </varlistentry>
582
583     <varlistentry>
584      <term><option>-l <replaceable>dbname</replaceable></option></term>
585      <term><option>--database=<replaceable>dbname</replaceable></option></term>
586      <listitem>
587       <para>
588         Specifies the name of the database to connect to for dumping global
589         objects and discovering what other databases should be dumped. If
590         not specified, the <literal>postgres</literal> database will be used,
591         and if that does not exist, <literal>template1</literal> will be used.
592       </para>
593      </listitem>
594     </varlistentry>
595
596     <varlistentry>
597      <term><option>-p <replaceable>port</replaceable></option></term>
598      <term><option>--port=<replaceable>port</replaceable></option></term>
599      <listitem>
600       <para>
601        Specifies the TCP port or local Unix domain socket file
602        extension on which the server is listening for connections.
603        Defaults to the <envar>PGPORT</envar> environment variable, if
604        set, or a compiled-in default.
605       </para>
606      </listitem>
607     </varlistentry>
608
609     <varlistentry>
610      <term><option>-U <replaceable>username</replaceable></option></term>
611      <term><option>--username=<replaceable>username</replaceable></option></term>
612      <listitem>
613       <para>
614        User name to connect as.
615       </para>
616      </listitem>
617     </varlistentry>
618
619     <varlistentry>
620      <term><option>-w</option></term>
621      <term><option>--no-password</option></term>
622      <listitem>
623       <para>
624        Never issue a password prompt.  If the server requires
625        password authentication and a password is not available by
626        other means such as a <filename>.pgpass</filename> file, the
627        connection attempt will fail.  This option can be useful in
628        batch jobs and scripts where no user is present to enter a
629        password.
630       </para>
631      </listitem>
632     </varlistentry>
633
634     <varlistentry>
635      <term><option>-W</option></term>
636      <term><option>--password</option></term>
637      <listitem>
638       <para>
639        Force <application>pg_dumpall</application> to prompt for a
640        password before connecting to a database.
641       </para>
642
643       <para>
644        This option is never essential, since
645        <application>pg_dumpall</application> will automatically prompt
646        for a password if the server demands password authentication.
647        However, <application>pg_dumpall</application> will waste a
648        connection attempt finding out that the server wants a password.
649        In some cases it is worth typing <option>-W</option> to avoid the extra
650        connection attempt.
651       </para>
652
653       <para>
654        Note that the password prompt will occur again for each database
655        to be dumped.  Usually, it's better to set up a
656        <filename>~/.pgpass</filename> file than to rely on manual password entry.
657       </para>
658      </listitem>
659     </varlistentry>
660
661     <varlistentry>
662      <term><option>--role=<replaceable class="parameter">rolename</replaceable></option></term>
663      <listitem>
664       <para>
665        Specifies a role name to be used to create the dump.
666        This option causes <application>pg_dumpall</application> to issue a
667        <command>SET ROLE</command> <replaceable class="parameter">rolename</replaceable>
668        command after connecting to the database. It is useful when the
669        authenticated user (specified by <option>-U</option>) lacks privileges
670        needed by <application>pg_dumpall</application>, but can switch to a role with
671        the required rights.  Some installations have a policy against
672        logging in directly as a superuser, and use of this option allows
673        dumps to be made without violating the policy.
674       </para>
675      </listitem>
676     </varlistentry>
677   </variablelist>
678  </para>
679 </refsect1>
680
681
682 <refsect1>
683  <title>Environment</title>
684
685  <variablelist>
686   <varlistentry>
687    <term><envar>PGHOST</envar></term>
688    <term><envar>PGOPTIONS</envar></term>
689    <term><envar>PGPORT</envar></term>
690    <term><envar>PGUSER</envar></term>
691
692    <listitem>
693     <para>
694      Default connection parameters
695     </para>
696    </listitem>
697   </varlistentry>
698
699   <varlistentry>
700    <term><envar>PG_COLOR</envar></term>
701    <listitem>
702     <para>
703      Specifies whether to use color in diagnostic messages. Possible values
704      are <literal>always</literal>, <literal>auto</literal> and
705      <literal>never</literal>.
706     </para>
707    </listitem>
708   </varlistentry>
709  </variablelist>
710
711  <para>
712   This utility, like most other <productname>PostgreSQL</productname> utilities,
713   also uses the environment variables supported by <application>libpq</application>
714   (see <xref linkend="libpq-envars"/>).
715  </para>
716
717 </refsect1>
718
719
720 <refsect1>
721  <title>Notes</title>
722
723  <para>
724   Since <application>pg_dumpall</application> calls
725   <application>pg_dump</application> internally, some diagnostic
726   messages will refer to <application>pg_dump</application>.
727  </para>
728
729  <para>
730   The <option>--clean</option> option can be useful even when your
731   intention is to restore the dump script into a fresh cluster.  Use of
732   <option>--clean</option> authorizes the script to drop and re-create the
733   built-in <literal>postgres</literal> and <literal>template1</literal>
734   databases, ensuring that those databases will retain the same properties
735   (for instance, locale and encoding) that they had in the source cluster.
736   Without the option, those databases will retain their existing
737   database-level properties, as well as any pre-existing contents.
738  </para>
739
740  <para>
741   Once restored, it is wise to run <command>ANALYZE</command> on each
742   database so the optimizer has useful statistics. You
743   can also run <command>vacuumdb -a -z</command> to analyze all
744   databases.
745  </para>
746
747  <para>
748   The dump script should not be expected to run completely without errors.
749   In particular, because the script will issue <command>CREATE ROLE</command>
750   for every role existing in the source cluster, it is certain to get a
751   <quote>role already exists</quote> error for the bootstrap superuser,
752   unless the destination cluster was initialized with a different bootstrap
753   superuser name.  This error is harmless and should be ignored.  Use of
754   the <option>--clean</option> option is likely to produce additional
755   harmless error messages about non-existent objects, although you can
756   minimize those by adding <option>--if-exists</option>.
757  </para>
758
759  <para>
760   <application>pg_dumpall</application> requires all needed
761   tablespace directories to exist before the restore;  otherwise,
762   database creation will fail for databases in non-default
763   locations.
764  </para>
765 </refsect1>
766
767
768 <refsect1 id="app-pg-dumpall-ex">
769  <title>Examples</title>
770  <para>
771   To dump all databases:
772
773<screen>
774<prompt>$</prompt> <userinput>pg_dumpall &gt; db.out</userinput>
775</screen>
776  </para>
777
778  <para>
779   To reload database(s) from this file, you can use:
780<screen>
781<prompt>$</prompt> <userinput>psql -f db.out postgres</userinput>
782</screen>
783   It is not important to which database you connect here since the
784   script file created by <application>pg_dumpall</application> will
785   contain the appropriate commands to create and connect to the saved
786   databases.  An exception is that if you specified <option>--clean</option>,
787   you must connect to the <literal>postgres</literal> database initially;
788   the script will attempt to drop other databases immediately, and that
789   will fail for the database you are connected to.
790  </para>
791 </refsect1>
792
793 <refsect1>
794  <title>See Also</title>
795
796  <para>
797    Check <xref linkend="app-pgdump"/> for details on possible
798    error conditions.
799  </para>
800 </refsect1>
801
802</refentry>
803