]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/pg_restore.sgml
Create a "sort support" interface API for faster sorting.
[postgresql] / doc / src / sgml / ref / pg_restore.sgml
1 <!-- doc/src/sgml/ref/pg_restore.sgml -->
2
3 <refentry id="APP-PGRESTORE">
4  <refmeta>
5   <refentrytitle>pg_restore</refentrytitle>
6   <manvolnum>1</manvolnum>
7   <refmiscinfo>Application</refmiscinfo>
8  </refmeta>
9
10  <refnamediv>
11   <refname>pg_restore</refname>
12
13   <refpurpose>
14    restore a <productname>PostgreSQL</productname> database from an
15    archive file created by <application>pg_dump</application>
16   </refpurpose>
17  </refnamediv>
18
19  <indexterm zone="app-pgrestore">
20   <primary>pg_restore</primary>
21  </indexterm>
22
23  <refsynopsisdiv>
24   <cmdsynopsis>
25    <command>pg_restore</command>
26    <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
27    <arg rep="repeat"><replaceable>option</replaceable></arg>
28    <arg><replaceable>filename</replaceable></arg>
29   </cmdsynopsis>
30  </refsynopsisdiv>
31
32
33  <refsect1 id="app-pgrestore-description">
34   <title>Description</title>
35
36   <para>
37    <application>pg_restore</application> is a utility for restoring a
38    <productname>PostgreSQL</productname> database from an archive
39    created by <xref linkend="app-pgdump"> in one of the non-plain-text
40    formats.  It will issue the commands necessary to reconstruct the
41    database to the state it was in at the time it was saved.  The
42    archive files also allow <application>pg_restore</application> to
43    be selective about what is restored, or even to reorder the items
44    prior to being restored. The archive files are designed to be
45    portable across architectures.
46   </para>
47
48   <para>
49    <application>pg_restore</application> can operate in two modes.
50    If a database name is specified, <application>pg_restore</application>
51    connects to that database and restores archive contents directly into
52    the database.  Otherwise, a script containing the SQL
53    commands necessary to rebuild the database is created and written
54    to a file or standard output.  This script output is equivalent to
55    the plain text output format of <application>pg_dump</application>.
56    Some of the options controlling the output are therefore analogous to
57    <application>pg_dump</application> options.
58   </para>
59
60   <para>
61    Obviously, <application>pg_restore</application> cannot restore information
62    that is not present in the archive file.  For instance, if the
63    archive was made using the <quote>dump data as
64    <command>INSERT</command> commands</quote> option,
65    <application>pg_restore</application> will not be able to load the data
66    using <command>COPY</command> statements.
67   </para>
68  </refsect1>
69
70  <refsect1 id="app-pgrestore-options">
71   <title>Options</title>
72
73    <para>
74     <application>pg_restore</application> accepts the following command
75     line arguments.
76
77     <variablelist>
78      <varlistentry>
79       <term><replaceable class="parameter">filename</replaceable></term>
80       <listitem>
81        <para>
82        Specifies the location of the archive file (or directory, for a
83        directory-format archive) to be restored.
84        If not specified, the standard input is used.
85        </para>
86       </listitem>
87      </varlistentry>
88
89      <varlistentry>
90       <term><option>-a</option></term>
91       <term><option>--data-only</option></term>
92       <listitem>
93        <para>
94         Restore only the data, not the schema (data definitions).
95        </para>
96       </listitem>
97      </varlistentry>
98
99      <varlistentry>
100       <term><option>-c</option></term>
101       <term><option>--clean</option></term>
102       <listitem>
103        <para>
104         Clean (drop) database objects before recreating them.
105        </para>
106       </listitem>
107      </varlistentry>
108
109      <varlistentry>
110       <term><option>-C</option></term>
111       <term><option>--create</option></term>
112       <listitem>
113        <para>
114         Create the database before restoring into it.  (When this
115         option is used, the database named with <option>-d</option> is
116         used only to issue the initial <command>CREATE DATABASE</>
117         command.  All data is restored into the database name that
118         appears in the archive.)
119        </para>
120       </listitem>
121      </varlistentry>
122
123      <varlistentry>
124       <term><option>-d <replaceable class="parameter">dbname</replaceable></option></term>
125       <term><option>--dbname=<replaceable class="parameter">dbname</replaceable></option></term>
126       <listitem>
127        <para>
128         Connect to database <replaceable
129         class="parameter">dbname</replaceable> and restore directly
130         into the database.
131        </para>
132       </listitem>
133      </varlistentry>
134
135      <varlistentry>
136       <term><option>-e</option></term>
137       <term><option>--exit-on-error</option></term>
138       <listitem>
139        <para>
140         Exit if an error is encountered while sending SQL commands to
141         the database. The default is to continue and to display a count of
142         errors at the end of the restoration.
143        </para>
144       </listitem>
145      </varlistentry>
146
147      <varlistentry>
148       <term><option>-f <replaceable>filename</replaceable></option></term>
149       <term><option>--file=<replaceable>filename</replaceable></option></term>
150       <listitem>
151        <para>
152         Specify output file for generated script, or for the listing
153         when used with <option>-l</option>. Default is the standard
154         output.
155        </para>
156       </listitem>
157      </varlistentry>
158
159      <varlistentry>
160       <term><option>-F <replaceable class="parameter">format</replaceable></option></term>
161       <term><option>--format=<replaceable class="parameter">format</replaceable></option></term>
162       <listitem>
163        <para>
164         Specify format of the archive.  It is not necessary to specify
165         the format, since <application>pg_restore</application> will
166         determine the format automatically. If specified, it can be
167         one of the following:
168
169        <variablelist>
170         <varlistentry>
171          <term><literal>c</></term>
172          <term><literal>custom</></term>
173          <listitem>
174           <para>
175            The archive is in the custom format of
176            <application>pg_dump</application>.
177           </para>
178          </listitem>
179         </varlistentry>
180
181         <varlistentry>
182          <term><literal>d</></term>
183          <term><literal>directory</></term>
184          <listitem>
185           <para>
186            The archive is a directory archive.
187           </para>
188          </listitem>
189         </varlistentry>
190
191         <varlistentry>
192          <term><literal>t</></term>
193          <term><literal>tar</></term>
194          <listitem>
195           <para>
196            The archive is a <command>tar</command> archive.
197           </para>
198          </listitem>
199         </varlistentry>
200        </variablelist></para>
201       </listitem>
202      </varlistentry>
203
204      <varlistentry>
205       <term><option>-i</option></term>
206       <term><option>--ignore-version</option></term>
207       <listitem>
208        <para>
209         A deprecated option that is now ignored.
210        </para>
211       </listitem>
212      </varlistentry>
213
214      <varlistentry>
215       <term><option>-I <replaceable class="parameter">index</replaceable></option></term>
216       <term><option>--index=<replaceable class="parameter">index</replaceable></option></term>
217       <listitem>
218        <para>
219         Restore definition of named index only.
220        </para>
221       </listitem>
222      </varlistentry>
223
224      <varlistentry>
225       <term><option>-j <replaceable class="parameter">number-of-jobs</replaceable></option></term>
226       <term><option>--jobs=<replaceable class="parameter">number-of-jobs</replaceable></option></term>
227       <listitem>
228        <para>
229         Run the most time-consuming parts
230         of <application>pg_restore</> &mdash; those which load data,
231         create indexes, or create constraints &mdash; using multiple
232         concurrent jobs.  This option can dramatically reduce the time
233         to restore a large database to a server running on a
234         multiprocessor machine.
235        </para>
236
237        <para>
238         Each job is one process or one thread, depending on the
239         operating system, and uses a separate connection to the
240         server.
241        </para>
242
243        <para>
244         The optimal value for this option depends on the hardware
245         setup of the server, of the client, and of the network.
246         Factors include the number of CPU cores and the disk setup.  A
247         good place to start is the number of CPU cores on the server,
248         but values larger than that can also lead to faster restore
249         times in many cases.  Of course, values that are too high will
250         lead to decreased performance because of thrashing.
251        </para>
252
253        <para>
254         Only the custom archive format is supported with this option.
255         The input file must be a regular file (not, for example, a
256         pipe).  This option is ignored when emitting a script rather
257         than connecting directly to a database server.  Also, multiple
258         jobs cannot be used together with the
259         option <option>--single-transaction</option>.
260        </para>
261       </listitem>
262      </varlistentry>
263
264      <varlistentry>
265       <term><option>-l</option></term>
266       <term><option>--list</option></term>
267       <listitem>
268        <para>
269         List the contents of the archive. The output of this operation
270         can be used as input to the <option>-L</option> option.  Note that
271         if filtering switches such as <option>-n</> or <option>-t</> are
272         used with <option>-l</>, they will restrict the items listed.
273        </para>
274       </listitem>
275      </varlistentry>
276
277      <varlistentry>
278       <term><option>-L <replaceable class="parameter">list-file</replaceable></option></term>
279       <term><option>--use-list=<replaceable class="parameter">list-file</replaceable></option></term>
280       <listitem>
281        <para>
282         Restore only those archive elements that are listed in <replaceable
283         class="PARAMETER">list-file</replaceable>, and restore them in the
284         order they appear in the file.  Note that
285         if filtering switches such as <option>-n</> or <option>-t</> are
286         used with <option>-L</>, they will further restrict the items restored.
287        </para>
288        <para><replaceable class="PARAMETER">list-file</> is normally created by
289         editing the output of a previous <option>-l</> operation.
290         Lines can be moved or removed, and can also
291         be commented out by placing a semicolon (<literal>;</literal>) at the
292         start of the line.  See below for examples.
293        </para>
294       </listitem>
295      </varlistentry>
296
297      <varlistentry>
298       <term><option>-n <replaceable class="parameter">namespace</replaceable></option></term>
299       <term><option>--schema=<replaceable class="parameter">schema</replaceable></option></term>
300       <listitem>
301        <para>
302         Restore only objects that are in the named schema.  This can be
303         combined with the <option>-t</option> option to restore just a
304         specific table.
305        </para>
306       </listitem>
307      </varlistentry>
308
309      <varlistentry>
310       <term><option>-O</option></term>
311       <term><option>--no-owner</option></term>
312       <listitem>
313        <para>
314         Do not output commands to set
315         ownership of objects to match the original database.
316         By default, <application>pg_restore</application> issues
317         <command>ALTER OWNER</> or
318         <command>SET SESSION AUTHORIZATION</command>
319         statements to set ownership of created schema elements.
320         These statements will fail unless the initial connection to the
321         database is made by a superuser
322         (or the same user that owns all of the objects in the script).
323         With <option>-O</option>, any user name can be used for the
324         initial connection, and this user will own all the created objects.
325        </para>
326       </listitem>
327      </varlistentry>
328
329      <varlistentry>
330       <term><option>-P <replaceable class="parameter">function-name(argtype [, ...])</replaceable></option></term>
331       <term><option>--function=<replaceable class="parameter">function-name(argtype [, ...])</replaceable></option></term>
332       <listitem>
333        <para>
334         Restore the named function only.  Be careful to spell the function
335         name and arguments exactly as they appear in the dump file's table
336         of contents.
337        </para>
338       </listitem>
339      </varlistentry>
340
341      <varlistentry>
342       <term><option>-R</option></term>
343       <term><option>--no-reconnect</option></term>
344       <listitem>
345        <para>
346         This option is obsolete but still accepted for backwards
347         compatibility.
348        </para>
349       </listitem>
350      </varlistentry>
351
352      <varlistentry>
353       <term><option>-s</option></term>
354       <term><option>--schema-only</option></term>
355       <listitem>
356        <para>
357         Restore only the schema (data definitions), not the data (table
358         contents).  Current sequence values will not be restored, either.
359         (Do not confuse this with the <option>--schema</> option, which
360         uses the word <quote>schema</> in a different meaning.)
361        </para>
362       </listitem>
363      </varlistentry>
364
365      <varlistentry>
366       <term><option>-S <replaceable class="parameter">username</replaceable></option></term>
367       <term><option>--superuser=<replaceable class="parameter">username</replaceable></option></term>
368       <listitem>
369        <para>
370         Specify the superuser user name to use when disabling triggers.
371         This is only relevant if <option>--disable-triggers</> is used.
372        </para>
373       </listitem>
374      </varlistentry>
375
376      <varlistentry>
377       <term><option>-t <replaceable class="parameter">table</replaceable></option></term>
378       <term><option>--table=<replaceable class="parameter">table</replaceable></option></term>
379       <listitem>
380        <para>
381         Restore definition and/or data of named table only.  This can be
382         combined with the <option>-n</option> option to specify a schema.
383        </para>
384       </listitem>
385      </varlistentry>
386
387      <varlistentry>
388       <term><option>-T <replaceable class="parameter">trigger</replaceable></option></term>
389       <term><option>--trigger=<replaceable class="parameter">trigger</replaceable></option></term>
390       <listitem>
391        <para>
392         Restore named trigger only.
393        </para>
394       </listitem>
395      </varlistentry>
396
397      <varlistentry>
398       <term><option>-v</option></term>
399       <term><option>--verbose</option></term>
400       <listitem>
401        <para>
402         Specifies verbose mode.
403        </para>
404       </listitem>
405      </varlistentry>
406
407      <varlistentry>
408        <term><option>-V</></term>
409        <term><option>--version</></term>
410        <listitem>
411        <para>
412        Print the <application>pg_restore</application> version and exit.
413        </para>
414        </listitem>
415      </varlistentry>
416
417      <varlistentry>
418       <term><option>-x</option></term>
419       <term><option>--no-privileges</option></term>
420       <term><option>--no-acl</option></term>
421       <listitem>
422        <para>
423         Prevent restoration of access privileges (grant/revoke commands).
424        </para>
425       </listitem>
426      </varlistentry>
427
428      <varlistentry>
429       <term><option>-1</option></term>
430       <term><option>--single-transaction</option></term>
431       <listitem>
432        <para>
433         Execute the restore as a single transaction (that is, wrap the
434         emitted commands in <command>BEGIN</>/<command>COMMIT</>).  This
435         ensures that either all the commands complete successfully, or no
436         changes are applied. This option implies
437         <option>--exit-on-error</>.
438        </para>
439       </listitem>
440      </varlistentry>
441
442      <varlistentry>
443       <term><option>--disable-triggers</></term>
444       <listitem>
445        <para>
446         This option is only relevant when performing a data-only restore.
447         It instructs <application>pg_restore</application> to execute commands
448         to temporarily disable triggers on the target tables while
449         the data is reloaded.  Use this if you have referential
450         integrity checks or other triggers on the tables that you
451         do not want to invoke during data reload.
452        </para>
453
454        <para>
455         Presently, the commands emitted for
456         <option>--disable-triggers</> must be done as superuser.  So, you
457         should also specify a superuser name with <option>-S</>, or
458         preferably run <application>pg_restore</application> as a
459         <productname>PostgreSQL</> superuser.
460        </para>
461       </listitem>
462      </varlistentry>
463
464      <varlistentry>
465       <term><option>--no-data-for-failed-tables</option></term>
466       <listitem>
467        <para>
468         By default, table data is restored even if the creation command
469         for the table failed (e.g., because it already exists).
470         With this option, data for such a table is skipped.
471         This behavior is useful if the target database already
472         contains the desired table contents.  For example,
473         auxiliary tables for <productname>PostgreSQL</> extensions
474         such as <productname>PostGIS</> might already be loaded in
475         the target database; specifying this option prevents duplicate
476         or obsolete data from being loaded into them.
477        </para>
478
479        <para>
480         This option is effective only when restoring directly into a
481         database, not when producing SQL script output.
482        </para>
483       </listitem>
484      </varlistentry>
485
486      <varlistentry>
487       <term><option>--no-security-labels</option></term>
488       <listitem>
489        <para>
490         Do not output commands to restore security labels,
491         even if the archive contains them.
492        </para>
493       </listitem>
494      </varlistentry>
495
496      <varlistentry>
497       <term><option>--no-tablespaces</option></term>
498       <listitem>
499        <para>
500         Do not output commands to select tablespaces.
501         With this option, all objects will be created in whichever
502         tablespace is the default during restore.
503        </para>
504       </listitem>
505      </varlistentry>
506
507      <varlistentry>
508       <term><option>--use-set-session-authorization</option></term>
509       <listitem>
510        <para>
511         Output SQL-standard <command>SET SESSION AUTHORIZATION</> commands
512         instead of <command>ALTER OWNER</> commands to determine object
513         ownership.  This makes the dump more standards-compatible, but
514         depending on the history of the objects in the dump, might not restore
515         properly.
516        </para>
517       </listitem>
518      </varlistentry>
519
520      <varlistentry>
521        <term><option>-?</></term>
522        <term><option>--help</></term>
523        <listitem>
524        <para>
525        Show help about <application>pg_restore</application> command line
526        arguments, and exit.
527        </para>
528        </listitem>
529      </varlistentry>
530
531     </variablelist>
532    </para>
533
534    <para>
535     <application>pg_restore</application> also accepts
536     the following command line arguments for connection parameters:
537
538     <variablelist>
539      <varlistentry>
540       <term><option>-h <replaceable class="parameter">host</replaceable></option></term>
541       <term><option>--host=<replaceable class="parameter">host</replaceable></option></term>
542       <listitem>
543        <para>
544         Specifies the host name of the machine on which the server is
545         running.  If the value begins with a slash, it is used as the
546         directory for the Unix domain socket. The default is taken
547         from the <envar>PGHOST</envar> environment variable, if set,
548         else a Unix domain socket connection is attempted.
549        </para>
550       </listitem>
551      </varlistentry>
552
553      <varlistentry>
554       <term><option>-p <replaceable class="parameter">port</replaceable></option></term>
555       <term><option>--port=<replaceable class="parameter">port</replaceable></option></term>
556       <listitem>
557        <para>
558         Specifies the TCP port or local Unix domain socket file
559         extension on which the server is listening for connections.
560         Defaults to the <envar>PGPORT</envar> environment variable, if
561         set, or a compiled-in default.
562         </para>
563       </listitem>
564      </varlistentry>
565
566      <varlistentry>
567       <term><option>-U <replaceable>username</replaceable></option></term>
568       <term><option>--username=<replaceable class="parameter">username</replaceable></option></term>
569       <listitem>
570        <para>
571         User name to connect as.
572        </para>
573       </listitem>
574      </varlistentry>
575
576      <varlistentry>
577       <term><option>-w</></term>
578       <term><option>--no-password</></term>
579       <listitem>
580        <para>
581         Never issue a password prompt.  If the server requires
582         password authentication and a password is not available by
583         other means such as a <filename>.pgpass</filename> file, the
584         connection attempt will fail.  This option can be useful in
585         batch jobs and scripts where no user is present to enter a
586         password.
587        </para>
588       </listitem>
589      </varlistentry>
590
591      <varlistentry>
592       <term><option>-W</option></term>
593       <term><option>--password</option></term>
594       <listitem>
595        <para>
596         Force <application>pg_restore</application> to prompt for a
597         password before connecting to a database.
598        </para>
599
600        <para>
601         This option is never essential, since
602         <application>pg_restore</application> will automatically prompt
603         for a password if the server demands password authentication.
604         However, <application>pg_restore</application> will waste a
605         connection attempt finding out that the server wants a password.
606         In some cases it is worth typing <option>-W</> to avoid the extra
607         connection attempt.
608        </para>
609       </listitem>
610      </varlistentry>
611
612      <varlistentry>
613       <term><option>--role=<replaceable class="parameter">rolename</replaceable></option></term>
614       <listitem>
615        <para>
616         Specifies a role name to be used to perform the restore.
617         This option causes <application>pg_restore</> to issue a
618         <command>SET ROLE</> <replaceable class="parameter">rolename</>
619         command after connecting to the database. It is useful when the
620         authenticated user (specified by <option>-U</>) lacks privileges
621         needed by <application>pg_restore</>, but can switch to a role with
622         the required rights.  Some installations have a policy against
623         logging in directly as a superuser, and use of this option allows
624         restores to be performed without violating the policy.
625        </para>
626       </listitem>
627      </varlistentry>
628
629     </variablelist>
630    </para>
631  </refsect1>
632
633
634  <refsect1>
635   <title>Environment</title>
636
637   <variablelist>
638    <varlistentry>
639     <term><envar>PGHOST</envar></term>
640     <term><envar>PGOPTIONS</envar></term>
641     <term><envar>PGPORT</envar></term>
642     <term><envar>PGUSER</envar></term>
643
644     <listitem>
645      <para>
646       Default connection parameters
647      </para>
648     </listitem>
649    </varlistentry>
650   </variablelist>
651
652   <para>
653    This utility, like most other <productname>PostgreSQL</> utilities,
654    also uses the environment variables supported by <application>libpq</>
655    (see <xref linkend="libpq-envars">).
656   </para>
657
658  </refsect1>
659
660
661  <refsect1 id="app-pgrestore-diagnostics">
662   <title>Diagnostics</title>
663
664   <para>
665    When a direct database connection is specified using the
666    <option>-d</option> option, <application>pg_restore</application>
667    internally executes <acronym>SQL</acronym> statements. If you have
668    problems running <application>pg_restore</application>, make sure
669    you are able to select information from the database using, for
670    example, <xref linkend="app-psql">.  Also, any default connection
671    settings and environment variables used by the
672    <application>libpq</application> front-end library will apply.
673   </para>
674  </refsect1>
675
676
677  <refsect1 id="app-pgrestore-notes">
678   <title>Notes</title>
679
680   <para>
681    If your installation has any local additions to the
682    <literal>template1</> database, be careful to load the output of
683    <application>pg_restore</application> into a truly empty database;
684    otherwise you are likely to get errors due to duplicate definitions
685    of the added objects.  To make an empty database without any local
686    additions, copy from <literal>template0</> not <literal>template1</>, for example:
687 <programlisting>
688 CREATE DATABASE foo WITH TEMPLATE template0;
689 </programlisting>
690   </para>
691
692   <para>
693    The limitations of <application>pg_restore</application> are detailed below.
694
695    <itemizedlist>
696     <listitem>
697      <para>
698       When restoring data to a pre-existing table and the option
699       <option>--disable-triggers</> is used,
700       <application>pg_restore</application> emits commands
701       to disable triggers on user tables before inserting the data, then emits commands to
702       re-enable them after the data has been inserted.  If the restore is stopped in the
703       middle, the system catalogs might be left in the wrong state.
704      </para>
705     </listitem>
706
707     <listitem>
708      <para><application>pg_restore</application> cannot restore large objects
709       selectively;  for instance, only those for a specific table.  If
710       an archive contains large objects, then all large objects will be
711       restored, or none of them if they are excluded via <option>-L</option>,
712       <option>-t</option>, or other options.
713      </para>
714     </listitem>
715
716    </itemizedlist>
717   </para>
718
719   <para>
720    See also the <xref linkend="app-pgdump"> documentation for details on
721    limitations of <application>pg_dump</application>.
722   </para>
723
724   <para>
725    Once restored, it is wise to run <command>ANALYZE</> on each
726    restored table so the optimizer has useful statistics; see
727    <xref linkend="vacuum-for-statistics"> and
728    <xref linkend="autovacuum"> for more information.
729   </para>
730
731  </refsect1>
732
733
734  <refsect1 id="app-pgrestore-examples">
735   <title>Examples</title>
736
737   <para>
738    Assume we have dumped a database called <literal>mydb</> into a
739    custom-format dump file:
740
741 <screen>
742 <prompt>$</prompt> <userinput>pg_dump -Fc mydb &gt; db.dump</userinput>
743 </screen>
744   </para>
745
746   <para>
747    To drop the database and recreate it from the dump:
748
749 <screen>
750 <prompt>$</prompt> <userinput>dropdb mydb</userinput>
751 <prompt>$</prompt> <userinput>pg_restore -C -d postgres db.dump</userinput>
752 </screen>
753
754    The database named in the <option>-d</> switch can be any database existing
755    in the cluster; <application>pg_restore</> only uses it to issue the
756    <command>CREATE DATABASE</> command for <literal>mydb</>.  With
757    <option>-C</>, data is always restored into the database name that appears
758    in the dump file.
759   </para>
760
761   <para>
762    To reload the dump into a new database called <literal>newdb</>:
763
764 <screen>
765 <prompt>$</prompt> <userinput>createdb -T template0 newdb</userinput>
766 <prompt>$</prompt> <userinput>pg_restore -d newdb db.dump</userinput>
767 </screen>
768
769    Notice we don't use <option>-C</>, and instead connect directly to the
770    database to be restored into.  Also note that we clone the new database
771    from <literal>template0</> not <literal>template1</>, to ensure it is
772    initially empty.
773   </para>
774
775   <para>
776    To reorder database items, it is first necessary to dump the table of
777    contents of the archive:
778 <screen>
779 <prompt>$</prompt> <userinput>pg_restore -l db.dump &gt; db.list</userinput>
780 </screen>
781    The listing file consists of a header and one line for each item, e.g.:
782 <programlisting>
783 ;
784 ; Archive created at Mon Sep 14 13:55:39 2009
785 ;     dbname: DBDEMOS
786 ;     TOC Entries: 81
787 ;     Compression: 9
788 ;     Dump Version: 1.10-0
789 ;     Format: CUSTOM
790 ;     Integer: 4 bytes
791 ;     Offset: 8 bytes
792 ;     Dumped from database version: 8.3.5
793 ;     Dumped by pg_dump version: 8.3.8
794 ;
795 ;
796 ; Selected TOC Entries:
797 ;
798 3; 2615 2200 SCHEMA - public pasha
799 1861; 0 0 COMMENT - SCHEMA public pasha
800 1862; 0 0 ACL - public pasha
801 317; 1247 17715 TYPE public composite pasha
802 319; 1247 25899 DOMAIN public domain0 pasha
803 </programlisting>
804    Semicolons start a comment, and the numbers at the start of lines refer to the
805    internal archive ID assigned to each item.
806   </para>
807
808   <para>
809    Lines in the file can be commented out, deleted, and reordered. For example:
810 <programlisting>
811 10; 145433 TABLE map_resolutions postgres
812 ;2; 145344 TABLE species postgres
813 ;4; 145359 TABLE nt_header postgres
814 6; 145402 TABLE species_records postgres
815 ;8; 145416 TABLE ss_old postgres
816 </programlisting>
817    could be used as input to <application>pg_restore</application> and would only restore
818    items 10 and 6, in that order:
819 <screen>
820 <prompt>$</prompt> <userinput>pg_restore -L db.list db.dump</userinput>
821 </screen></para>
822
823  </refsect1>
824
825  <refsect1>
826   <title>See Also</title>
827
828   <simplelist type="inline">
829    <member><xref linkend="app-pgdump"></member>
830    <member><xref linkend="app-pg-dumpall"></member>
831    <member><xref linkend="app-psql"></member>
832   </simplelist>
833  </refsect1>
834 </refentry>