1999-07-22 17:09:15 +02:00
|
|
|
<!--
|
2010-09-20 22:08:53 +02:00
|
|
|
doc/src/sgml/ref/pg_dump.sgml
|
2001-12-08 04:24:40 +01:00
|
|
|
PostgreSQL documentation
|
1999-07-22 17:09:15 +02:00
|
|
|
-->
|
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refentry id="app-pgdump">
|
2014-02-24 03:25:35 +01:00
|
|
|
<indexterm zone="app-pgdump">
|
|
|
|
<primary>pg_dump</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<refmeta>
|
2020-07-10 16:51:29 +02:00
|
|
|
<refentrytitle><application>pg_dump</application></refentrytitle>
|
2000-12-26 00:15:27 +01:00
|
|
|
<manvolnum>1</manvolnum>
|
1999-07-06 19:16:42 +02:00
|
|
|
<refmiscinfo>Application</refmiscinfo>
|
|
|
|
</refmeta>
|
2001-03-06 19:55:57 +01:00
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<refnamediv>
|
2001-03-06 19:55:57 +01:00
|
|
|
<refname>pg_dump</refname>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<refpurpose>
|
2006-10-10 01:36:59 +02:00
|
|
|
extract a <productname>PostgreSQL</productname> database into a script file or other archive file
|
1999-07-06 19:16:42 +02:00
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
2001-03-06 19:55:57 +01:00
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<refsynopsisdiv>
|
2001-03-06 19:55:57 +01:00
|
|
|
<cmdsynopsis>
|
|
|
|
<command>pg_dump</command>
|
2010-02-19 04:50:03 +01:00
|
|
|
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
|
2003-03-24 15:32:51 +01:00
|
|
|
<arg rep="repeat"><replaceable>option</replaceable></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><replaceable>dbname</replaceable></arg>
|
2001-03-06 19:55:57 +01:00
|
|
|
</cmdsynopsis>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
|
|
|
|
<refsect1 id="pg-dump-description">
|
2020-06-07 13:10:18 +02:00
|
|
|
<title>Description</title>
|
2001-03-06 19:55:57 +01:00
|
|
|
|
|
|
|
<para>
|
2003-04-17 17:34:37 +02:00
|
|
|
<application>pg_dump</application> is a utility for backing up a
|
|
|
|
<productname>PostgreSQL</productname> database. It makes consistent
|
|
|
|
backups even if the database is being used concurrently.
|
|
|
|
<application>pg_dump</application> does not block other users
|
|
|
|
accessing the database (readers or writers).
|
2002-10-12 01:03:48 +02:00
|
|
|
</para>
|
|
|
|
|
2015-06-14 03:45:56 +02:00
|
|
|
<para>
|
Move handling of database properties from pg_dumpall into pg_dump.
This patch rearranges the division of labor between pg_dump and pg_dumpall
so that pg_dump itself handles all properties attached to a single
database. Notably, a database's ACL (GRANT/REVOKE status) and local GUC
settings established by ALTER DATABASE SET and ALTER ROLE IN DATABASE SET
can be dumped and restored by pg_dump. This is a long-requested
improvement.
"pg_dumpall -g" will now produce only role- and tablespace-related output,
nothing about individual databases. The total output of a regular
pg_dumpall run remains the same.
pg_dump (or pg_restore) will restore database-level properties only when
creating the target database with --create. This applies not only to
ACLs and GUCs but to the other database properties it already handled,
that is database comments and security labels. This is more consistent
and useful, but does represent an incompatibility in the behavior seen
without --create.
(This change makes the proposed patch to have pg_dump use "COMMENT ON
DATABASE CURRENT_DATABASE" unnecessary, since there is no case where
the command is issued that we won't know the true name of the database.
We might still want that patch as a feature in its own right, but pg_dump
no longer needs it.)
pg_dumpall with --clean will now drop and recreate the "postgres" and
"template1" databases in the target cluster, allowing their locale and
encoding settings to be changed if necessary, and providing a cleaner
way to set nondefault tablespaces for them than we had before. This
means that such a script must now always be started in the "postgres"
database; the order of drops and reconnects will not work otherwise.
Without --clean, the script will not adjust any database-level properties
of those two databases (including their comments, ACLs, and security
labels, which it formerly would try to set).
Another minor incompatibility is that the CREATE DATABASE commands in a
pg_dumpall script will now always specify locale and encoding settings.
Formerly those would be omitted if they matched the cluster's default.
While that behavior had some usefulness in some migration scenarios,
it also posed a significant hazard of unwanted locale/encoding changes.
To migrate to another locale/encoding, it's now necessary to use pg_dump
without --create to restore into a database with the desired settings.
Commit 4bd371f6f's hack to emit "SET default_transaction_read_only = off"
is gone: we now dodge that problem by the expedient of not issuing ALTER
DATABASE SET commands until after reconnecting to the target database.
Therefore, such settings won't apply during the restore session.
In passing, improve some shaky grammar in the docs, and add a note pointing
out that pg_dumpall's output can't be expected to load without any errors.
(Someday we might want to fix that, but this is not that patch.)
Haribabu Kommi, reviewed at various times by Andreas Karlsson,
Vaishnavi Prabakaran, and Robert Haas; further hacking by me.
Discussion: https://postgr.es/m/CAJrrPGcUurV0eWTeXODwsOYFN=Ekq36t1s0YnFYUNzsmRfdAyA@mail.gmail.com
2018-01-22 20:09:09 +01:00
|
|
|
<application>pg_dump</application> only dumps a single database.
|
|
|
|
To back up an entire cluster, or to back up global objects that are
|
|
|
|
common to all databases in a cluster (such as roles and tablespaces),
|
|
|
|
use <xref linkend="app-pg-dumpall"/>.
|
2015-06-14 03:45:56 +02:00
|
|
|
</para>
|
|
|
|
|
2002-10-12 01:03:48 +02:00
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
Dumps can be output in script or archive file formats. Script
|
|
|
|
dumps are plain-text files containing the SQL commands required
|
2003-04-17 17:34:37 +02:00
|
|
|
to reconstruct the database to the state it was in at the time it was
|
2005-01-04 04:58:16 +01:00
|
|
|
saved. To restore from such a script, feed it to <xref
|
2017-11-23 15:39:47 +01:00
|
|
|
linkend="app-psql"/>. Script files
|
2003-04-17 17:34:37 +02:00
|
|
|
can be used to reconstruct the database even on other machines and
|
2010-02-19 04:50:03 +01:00
|
|
|
other architectures; with some modifications, even on other SQL
|
2003-04-17 17:34:37 +02:00
|
|
|
database products.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
The alternative archive file formats must be used with
|
2017-11-23 15:39:47 +01:00
|
|
|
<xref linkend="app-pgrestore"/> to rebuild the database. They
|
2003-04-17 17:34:37 +02:00
|
|
|
allow <application>pg_restore</application> to be selective about
|
|
|
|
what is restored, or even to reorder the items prior to being
|
2005-06-21 22:45:44 +02:00
|
|
|
restored.
|
|
|
|
The archive file formats are designed to be portable across
|
2001-08-22 22:23:24 +02:00
|
|
|
architectures.
|
2001-03-06 19:55:57 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2001-08-22 22:23:24 +02:00
|
|
|
When used with one of the archive file formats and combined with
|
2003-04-17 17:34:37 +02:00
|
|
|
<application>pg_restore</application>,
|
|
|
|
<application>pg_dump</application> provides a flexible archival and
|
2002-10-12 01:03:48 +02:00
|
|
|
transfer mechanism. <application>pg_dump</application> can be used to
|
2003-04-17 17:34:37 +02:00
|
|
|
backup an entire database, then <application>pg_restore</application>
|
|
|
|
can be used to examine the archive and/or select which parts of the
|
2013-03-24 16:27:20 +01:00
|
|
|
database are to be restored. The most flexible output file formats are
|
|
|
|
the <quote>custom</quote> format (<option>-Fc</option>) and the
|
2018-10-29 12:34:49 +01:00
|
|
|
<quote>directory</quote> format (<option>-Fd</option>). They allow
|
2013-03-24 16:27:20 +01:00
|
|
|
for selection and reordering of all archived items, support parallel
|
|
|
|
restoration, and are compressed by default. The <quote>directory</quote>
|
|
|
|
format is the only format that supports parallel dumps.
|
2001-08-22 22:23:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2003-03-24 15:32:51 +01:00
|
|
|
While running <application>pg_dump</application>, one should examine the
|
2001-08-22 22:23:24 +02:00
|
|
|
output for any warnings (printed on standard error), especially in
|
|
|
|
light of the limitations listed below.
|
|
|
|
</para>
|
|
|
|
|
2002-08-27 20:57:26 +02:00
|
|
|
</refsect1>
|
2001-03-06 19:55:57 +01:00
|
|
|
|
2002-08-27 20:57:26 +02:00
|
|
|
<refsect1 id="pg-dump-options">
|
|
|
|
<title>Options</title>
|
2001-03-06 19:55:57 +01:00
|
|
|
|
2002-08-27 20:57:26 +02:00
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
The following command-line options control the content and
|
|
|
|
format of the output.
|
1999-07-06 19:16:42 +02:00
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">dbname</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
Specifies the name of the database to be dumped. If this is
|
|
|
|
not specified, the environment variable
|
|
|
|
<envar>PGDATABASE</envar> is used. If that is not set, the
|
|
|
|
user name specified for the connection is used.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-a</option></term>
|
|
|
|
<term><option>--data-only</option></term>
|
1999-07-06 19:16:42 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
Dump only the data, not the schema (data definitions).
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
Table data, large objects, and sequence values are dumped.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
2001-10-24 00:11:22 +02:00
|
|
|
|
|
|
|
<para>
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
This option is similar to, but for historical reasons not identical
|
2017-10-09 03:44:17 +02:00
|
|
|
to, specifying <option>--section=data</option>.
|
2001-10-24 00:11:22 +02:00
|
|
|
</para>
|
1999-07-06 19:16:42 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2006-10-10 01:36:59 +02:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-b</option></term>
|
2022-12-05 08:52:11 +01:00
|
|
|
<term><option>--large-objects</option></term>
|
|
|
|
<term><option>--blobs</option> (deprecated)</term>
|
2006-10-10 01:36:59 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Include large objects in the dump. This is the default behavior
|
2017-10-09 03:44:17 +02:00
|
|
|
except when <option>--schema</option>, <option>--table</option>, or
|
|
|
|
<option>--schema-only</option> is specified. The <option>-b</option>
|
2016-11-29 16:35:04 +01:00
|
|
|
switch is therefore only useful to add large objects to dumps
|
|
|
|
where a specific schema or table has been requested. Note that
|
2022-12-05 08:52:11 +01:00
|
|
|
large objects are considered data and therefore will be included when
|
Move handling of database properties from pg_dumpall into pg_dump.
This patch rearranges the division of labor between pg_dump and pg_dumpall
so that pg_dump itself handles all properties attached to a single
database. Notably, a database's ACL (GRANT/REVOKE status) and local GUC
settings established by ALTER DATABASE SET and ALTER ROLE IN DATABASE SET
can be dumped and restored by pg_dump. This is a long-requested
improvement.
"pg_dumpall -g" will now produce only role- and tablespace-related output,
nothing about individual databases. The total output of a regular
pg_dumpall run remains the same.
pg_dump (or pg_restore) will restore database-level properties only when
creating the target database with --create. This applies not only to
ACLs and GUCs but to the other database properties it already handled,
that is database comments and security labels. This is more consistent
and useful, but does represent an incompatibility in the behavior seen
without --create.
(This change makes the proposed patch to have pg_dump use "COMMENT ON
DATABASE CURRENT_DATABASE" unnecessary, since there is no case where
the command is issued that we won't know the true name of the database.
We might still want that patch as a feature in its own right, but pg_dump
no longer needs it.)
pg_dumpall with --clean will now drop and recreate the "postgres" and
"template1" databases in the target cluster, allowing their locale and
encoding settings to be changed if necessary, and providing a cleaner
way to set nondefault tablespaces for them than we had before. This
means that such a script must now always be started in the "postgres"
database; the order of drops and reconnects will not work otherwise.
Without --clean, the script will not adjust any database-level properties
of those two databases (including their comments, ACLs, and security
labels, which it formerly would try to set).
Another minor incompatibility is that the CREATE DATABASE commands in a
pg_dumpall script will now always specify locale and encoding settings.
Formerly those would be omitted if they matched the cluster's default.
While that behavior had some usefulness in some migration scenarios,
it also posed a significant hazard of unwanted locale/encoding changes.
To migrate to another locale/encoding, it's now necessary to use pg_dump
without --create to restore into a database with the desired settings.
Commit 4bd371f6f's hack to emit "SET default_transaction_read_only = off"
is gone: we now dodge that problem by the expedient of not issuing ALTER
DATABASE SET commands until after reconnecting to the target database.
Therefore, such settings won't apply during the restore session.
In passing, improve some shaky grammar in the docs, and add a note pointing
out that pg_dumpall's output can't be expected to load without any errors.
(Someday we might want to fix that, but this is not that patch.)
Haribabu Kommi, reviewed at various times by Andreas Karlsson,
Vaishnavi Prabakaran, and Robert Haas; further hacking by me.
Discussion: https://postgr.es/m/CAJrrPGcUurV0eWTeXODwsOYFN=Ekq36t1s0YnFYUNzsmRfdAyA@mail.gmail.com
2018-01-22 20:09:09 +01:00
|
|
|
<option>--data-only</option> is used, but not
|
|
|
|
when <option>--schema-only</option> is.
|
2006-10-10 01:36:59 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2016-11-29 17:09:35 +01:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-B</option></term>
|
2022-12-05 08:52:11 +01:00
|
|
|
<term><option>--no-large-objects</option></term>
|
|
|
|
<term><option>--no-blobs</option> (deprecated)</term>
|
2016-11-29 17:09:35 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Exclude large objects in the dump.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
When both <option>-b</option> and <option>-B</option> are given, the behavior
|
2016-11-29 17:09:35 +01:00
|
|
|
is to output large objects, when data is being dumped, see the
|
2017-10-09 03:44:17 +02:00
|
|
|
<option>-b</option> documentation.
|
2016-11-29 17:09:35 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2001-03-05 19:42:57 +01:00
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-c</option></term>
|
|
|
|
<term><option>--clean</option></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2023-09-29 19:13:54 +02:00
|
|
|
Output commands to <command>DROP</command> all the dumped
|
2011-05-19 00:14:45 +02:00
|
|
|
database objects prior to outputting the commands for creating them.
|
2023-09-29 19:13:54 +02:00
|
|
|
This option is useful when the restore is to overwrite an existing
|
|
|
|
database. If any of the objects do not exist in the destination
|
|
|
|
database, ignorable error messages will be reported during
|
|
|
|
restore, unless <option>--if-exists</option> is also specified.
|
2001-10-24 00:11:22 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2021-01-13 19:30:04 +01:00
|
|
|
This option is ignored when emitting an archive (non-text) output
|
|
|
|
file. For the archive formats, you can specify the option when you
|
2001-10-24 00:11:22 +02:00
|
|
|
call <command>pg_restore</command>.
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-C</option></term>
|
|
|
|
<term><option>--create</option></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
Begin the output with a command to create the
|
|
|
|
database itself and reconnect to the created database. (With a
|
2012-10-20 22:58:32 +02:00
|
|
|
script of this form, it doesn't matter which database in the
|
|
|
|
destination installation you connect to before running the script.)
|
|
|
|
If <option>--clean</option> is also specified, the script drops and
|
|
|
|
recreates the target database before reconnecting to it.
|
2001-10-24 00:11:22 +02:00
|
|
|
</para>
|
|
|
|
|
Move handling of database properties from pg_dumpall into pg_dump.
This patch rearranges the division of labor between pg_dump and pg_dumpall
so that pg_dump itself handles all properties attached to a single
database. Notably, a database's ACL (GRANT/REVOKE status) and local GUC
settings established by ALTER DATABASE SET and ALTER ROLE IN DATABASE SET
can be dumped and restored by pg_dump. This is a long-requested
improvement.
"pg_dumpall -g" will now produce only role- and tablespace-related output,
nothing about individual databases. The total output of a regular
pg_dumpall run remains the same.
pg_dump (or pg_restore) will restore database-level properties only when
creating the target database with --create. This applies not only to
ACLs and GUCs but to the other database properties it already handled,
that is database comments and security labels. This is more consistent
and useful, but does represent an incompatibility in the behavior seen
without --create.
(This change makes the proposed patch to have pg_dump use "COMMENT ON
DATABASE CURRENT_DATABASE" unnecessary, since there is no case where
the command is issued that we won't know the true name of the database.
We might still want that patch as a feature in its own right, but pg_dump
no longer needs it.)
pg_dumpall with --clean will now drop and recreate the "postgres" and
"template1" databases in the target cluster, allowing their locale and
encoding settings to be changed if necessary, and providing a cleaner
way to set nondefault tablespaces for them than we had before. This
means that such a script must now always be started in the "postgres"
database; the order of drops and reconnects will not work otherwise.
Without --clean, the script will not adjust any database-level properties
of those two databases (including their comments, ACLs, and security
labels, which it formerly would try to set).
Another minor incompatibility is that the CREATE DATABASE commands in a
pg_dumpall script will now always specify locale and encoding settings.
Formerly those would be omitted if they matched the cluster's default.
While that behavior had some usefulness in some migration scenarios,
it also posed a significant hazard of unwanted locale/encoding changes.
To migrate to another locale/encoding, it's now necessary to use pg_dump
without --create to restore into a database with the desired settings.
Commit 4bd371f6f's hack to emit "SET default_transaction_read_only = off"
is gone: we now dodge that problem by the expedient of not issuing ALTER
DATABASE SET commands until after reconnecting to the target database.
Therefore, such settings won't apply during the restore session.
In passing, improve some shaky grammar in the docs, and add a note pointing
out that pg_dumpall's output can't be expected to load without any errors.
(Someday we might want to fix that, but this is not that patch.)
Haribabu Kommi, reviewed at various times by Andreas Karlsson,
Vaishnavi Prabakaran, and Robert Haas; further hacking by me.
Discussion: https://postgr.es/m/CAJrrPGcUurV0eWTeXODwsOYFN=Ekq36t1s0YnFYUNzsmRfdAyA@mail.gmail.com
2018-01-22 20:09:09 +01:00
|
|
|
<para>
|
|
|
|
With <option>--create</option>, the output also includes the
|
|
|
|
database's comment if any, and any configuration variable settings
|
|
|
|
that are specific to this database, that is,
|
|
|
|
any <command>ALTER DATABASE ... SET ...</command>
|
|
|
|
and <command>ALTER ROLE ... IN DATABASE ... SET ...</command>
|
|
|
|
commands that mention this database.
|
|
|
|
Access privileges for the database itself are also dumped,
|
|
|
|
unless <option>--no-acl</option> is specified.
|
|
|
|
</para>
|
|
|
|
|
2001-10-24 00:11:22 +02:00
|
|
|
<para>
|
2021-01-13 19:30:04 +01:00
|
|
|
This option is ignored when emitting an archive (non-text) output
|
|
|
|
file. For the archive formats, you can specify the option when you
|
2001-10-24 00:11:22 +02:00
|
|
|
call <command>pg_restore</command>.
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
Add support for --extension in pg_dump
When specified, only extensions matching the given pattern are included
in dumps. Similarly to --table and --schema, when --strict-names is
used, a perfect match is required. Also, like the two other options,
this new option offers no guarantee that dependent objects have been
dumped, so a restore may fail on a clean database.
Tests are added in test_pg_dump/, checking after a set of positive and
negative cases, with or without an extension's contents added to the
dump generated.
Author: Guillaume Lelarge
Reviewed-by: David Fetter, Tom Lane, Michael Paquier, Asif Rehman,
Julien Rouhaud
Discussion: https://postgr.es/m/CAECtzeXOt4cnMU5+XMZzxBPJ_wu76pNy6HZKPRBL-j7yj1E4+g@mail.gmail.com
2021-03-31 02:12:34 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-e <replaceable class="parameter">pattern</replaceable></option></term>
|
|
|
|
<term><option>--extension=<replaceable class="parameter">pattern</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Dump only extensions matching <replaceable
|
|
|
|
class="parameter">pattern</replaceable>. When this option is not
|
|
|
|
specified, all non-system extensions in the target database will be
|
|
|
|
dumped. Multiple extensions can be selected by writing multiple
|
|
|
|
<option>-e</option> switches. The <replaceable
|
|
|
|
class="parameter">pattern</replaceable> parameter is interpreted as a
|
|
|
|
pattern according to the same rules used by
|
|
|
|
<application>psql</application>'s <literal>\d</literal> commands (see
|
|
|
|
<xref linkend="app-psql-patterns"/>), so multiple extensions can also
|
|
|
|
be selected by writing wildcard characters in the pattern. When using
|
|
|
|
wildcards, be careful to quote the pattern if needed to prevent the
|
|
|
|
shell from expanding the wildcards.
|
|
|
|
</para>
|
|
|
|
|
2021-04-15 03:03:46 +02:00
|
|
|
<para>
|
|
|
|
Any configuration relation registered by
|
|
|
|
<function>pg_extension_config_dump</function> is included in the
|
|
|
|
dump if its extension is specified by <option>--extension</option>.
|
|
|
|
</para>
|
|
|
|
|
Add support for --extension in pg_dump
When specified, only extensions matching the given pattern are included
in dumps. Similarly to --table and --schema, when --strict-names is
used, a perfect match is required. Also, like the two other options,
this new option offers no guarantee that dependent objects have been
dumped, so a restore may fail on a clean database.
Tests are added in test_pg_dump/, checking after a set of positive and
negative cases, with or without an extension's contents added to the
dump generated.
Author: Guillaume Lelarge
Reviewed-by: David Fetter, Tom Lane, Michael Paquier, Asif Rehman,
Julien Rouhaud
Discussion: https://postgr.es/m/CAECtzeXOt4cnMU5+XMZzxBPJ_wu76pNy6HZKPRBL-j7yj1E4+g@mail.gmail.com
2021-03-31 02:12:34 +02:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
When <option>-e</option> is specified,
|
|
|
|
<application>pg_dump</application> makes no attempt to dump any other
|
|
|
|
database objects that the selected extension(s) might depend upon.
|
|
|
|
Therefore, there is no guarantee that the results of a
|
|
|
|
specific-extension dump can be successfully restored by themselves
|
|
|
|
into a clean database.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2005-11-01 22:09:51 +01:00
|
|
|
<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,
|
|
|
|
the dump is created in the database encoding. (Another way to get the
|
|
|
|
same result is to set the <envar>PGCLIENTENCODING</envar> environment
|
2020-07-11 13:47:29 +02:00
|
|
|
variable to the desired dump encoding.) The supported encodings are
|
|
|
|
described in <xref linkend="multibyte-charset-supported"/>.
|
2005-11-01 22:09:51 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
2005-07-10 17:08:52 +02:00
|
|
|
</varlistentry>
|
|
|
|
|
2001-03-05 19:42:57 +01:00
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-f <replaceable class="parameter">file</replaceable></option></term>
|
|
|
|
<term><option>--file=<replaceable class="parameter">file</replaceable></option></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2011-01-23 22:10:15 +01:00
|
|
|
Send output to the specified file. This parameter can be omitted for
|
|
|
|
file based output formats, in which case the standard output is used.
|
|
|
|
It must be given for the directory output format however, where it
|
|
|
|
specifies the target directory instead of a file. In this case the
|
|
|
|
directory is created by <command>pg_dump</command> and must not exist
|
|
|
|
before.
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-F <replaceable class="parameter">format</replaceable></option></term>
|
|
|
|
<term><option>--format=<replaceable class="parameter">format</replaceable></option></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2001-08-22 22:23:24 +02:00
|
|
|
Selects the format of the output.
|
2005-01-04 04:58:16 +01:00
|
|
|
<replaceable>format</replaceable> can be one of the following:
|
2001-03-05 19:42:57 +01:00
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><literal>p</literal></term>
|
|
|
|
<term><literal>plain</literal></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2006-10-10 01:36:59 +02:00
|
|
|
Output a plain-text <acronym>SQL</acronym> script file (the default).
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><literal>c</literal></term>
|
|
|
|
<term><literal>custom</literal></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2010-02-23 18:28:09 +01:00
|
|
|
Output a custom-format archive suitable for input into
|
|
|
|
<application>pg_restore</application>.
|
2011-01-23 22:10:15 +01:00
|
|
|
Together with the directory output format, this is the most flexible
|
|
|
|
output format in that it allows manual selection and reordering of
|
|
|
|
archived items during restore. This format is also compressed by
|
|
|
|
default.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><literal>d</literal></term>
|
|
|
|
<term><literal>directory</literal></term>
|
2011-01-23 22:10:15 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Output a directory-format archive suitable for input into
|
|
|
|
<application>pg_restore</application>. This will create a directory
|
2022-12-05 08:52:11 +01:00
|
|
|
with one file for each table and large object being dumped, plus a
|
2011-01-23 22:10:15 +01:00
|
|
|
so-called Table of Contents file describing the dumped objects in a
|
|
|
|
machine-readable format that <application>pg_restore</application>
|
|
|
|
can read. A directory format archive can be manipulated with
|
|
|
|
standard Unix tools; for example, files in an uncompressed archive
|
2023-04-05 21:38:04 +02:00
|
|
|
can be compressed with the <application>gzip</application>,
|
|
|
|
<application>lz4</application>, or
|
|
|
|
<application>zstd</application> tools.
|
2023-02-23 21:19:19 +01:00
|
|
|
This format is compressed by default using <literal>gzip</literal>
|
|
|
|
and also supports parallel dumps.
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><literal>t</literal></term>
|
|
|
|
<term><literal>tar</literal></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2010-02-23 18:28:09 +01:00
|
|
|
Output a <command>tar</command>-format archive suitable for input
|
Adopt the GNU convention for handling tar-archive members exceeding 8GB.
The POSIX standard for tar headers requires archive member sizes to be
printed in octal with at most 11 digits, limiting the representable file
size to 8GB. However, GNU tar and apparently most other modern tars
support a convention in which oversized values can be stored in base-256,
allowing any practical file to be a tar member. Adopt this convention
to remove two limitations:
* pg_dump with -Ft output format failed if the contents of any one table
exceeded 8GB.
* pg_basebackup failed if the data directory contained any file exceeding
8GB. (This would be a fatal problem for installations configured with a
table segment size of 8GB or more, and it has also been seen to fail when
large core dump files exist in the data directory.)
File sizes under 8GB are still printed in octal, so that no compatibility
issues are created except in cases that would have failed entirely before.
In addition, this patch fixes several bugs in the same area:
* In 9.3 and later, we'd defined tarCreateHeader's file-size argument as
size_t, which meant that on 32-bit machines it would write a corrupt tar
header for file sizes between 4GB and 8GB, even though no error was raised.
This broke both "pg_dump -Ft" and pg_basebackup for such cases.
* pg_restore from a tar archive would fail on tables of size between 4GB
and 8GB, on machines where either "size_t" or "unsigned long" is 32 bits.
This happened even with an archive file not affected by the previous bug.
* pg_basebackup would fail if there were files of size between 4GB and 8GB,
even on 64-bit machines.
* In 9.3 and later, "pg_basebackup -Ft" failed entirely, for any file size,
on 64-bit big-endian machines.
In view of these potential data-loss bugs, back-patch to all supported
branches, even though removal of the documented 8GB limit might otherwise
be considered a new feature rather than a bug fix.
2015-11-22 02:21:31 +01:00
|
|
|
into <application>pg_restore</application>. The tar format is
|
|
|
|
compatible with the directory format: extracting a tar-format
|
2011-01-23 22:10:15 +01:00
|
|
|
archive produces a valid directory-format archive.
|
Adopt the GNU convention for handling tar-archive members exceeding 8GB.
The POSIX standard for tar headers requires archive member sizes to be
printed in octal with at most 11 digits, limiting the representable file
size to 8GB. However, GNU tar and apparently most other modern tars
support a convention in which oversized values can be stored in base-256,
allowing any practical file to be a tar member. Adopt this convention
to remove two limitations:
* pg_dump with -Ft output format failed if the contents of any one table
exceeded 8GB.
* pg_basebackup failed if the data directory contained any file exceeding
8GB. (This would be a fatal problem for installations configured with a
table segment size of 8GB or more, and it has also been seen to fail when
large core dump files exist in the data directory.)
File sizes under 8GB are still printed in octal, so that no compatibility
issues are created except in cases that would have failed entirely before.
In addition, this patch fixes several bugs in the same area:
* In 9.3 and later, we'd defined tarCreateHeader's file-size argument as
size_t, which meant that on 32-bit machines it would write a corrupt tar
header for file sizes between 4GB and 8GB, even though no error was raised.
This broke both "pg_dump -Ft" and pg_basebackup for such cases.
* pg_restore from a tar archive would fail on tables of size between 4GB
and 8GB, on machines where either "size_t" or "unsigned long" is 32 bits.
This happened even with an archive file not affected by the previous bug.
* pg_basebackup would fail if there were files of size between 4GB and 8GB,
even on 64-bit machines.
* In 9.3 and later, "pg_basebackup -Ft" failed entirely, for any file size,
on 64-bit big-endian machines.
In view of these potential data-loss bugs, back-patch to all supported
branches, even though removal of the documented 8GB limit might otherwise
be considered a new feature rather than a bug fix.
2015-11-22 02:21:31 +01:00
|
|
|
However, the tar format does not support compression. Also, when
|
|
|
|
using tar format the relative order of table data items cannot be
|
|
|
|
changed during restore.
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2011-08-07 09:49:45 +02:00
|
|
|
</variablelist></para>
|
2001-03-05 19:42:57 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
1999-07-06 19:16:42 +02:00
|
|
|
|
2013-03-24 16:27:20 +01:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-j <replaceable class="parameter">njobs</replaceable></option></term>
|
|
|
|
<term><option>--jobs=<replaceable class="parameter">njobs</replaceable></option></term>
|
2013-03-24 16:27:20 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Run the dump in parallel by dumping <replaceable class="parameter">njobs</replaceable>
|
2020-09-21 18:43:42 +02:00
|
|
|
tables simultaneously. This option may reduce the time needed to perform the dump but it also
|
2013-03-24 16:27:20 +01:00
|
|
|
increases the load on the database server. You can only use this option with the
|
|
|
|
directory output format because this is the only output format where multiple processes
|
|
|
|
can write their data at the same time.
|
|
|
|
</para>
|
2017-10-09 03:44:17 +02:00
|
|
|
<para><application>pg_dump</application> will open <replaceable class="parameter">njobs</replaceable>
|
2017-11-23 15:39:47 +01:00
|
|
|
+ 1 connections to the database, so make sure your <xref linkend="guc-max-connections"/>
|
2013-03-24 16:27:20 +01:00
|
|
|
setting is high enough to accommodate all connections.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Requesting exclusive locks on database objects while running a parallel dump could
|
2020-06-14 23:22:47 +02:00
|
|
|
cause the dump to fail. The reason is that the <application>pg_dump</application> leader process
|
2022-07-01 06:41:36 +02:00
|
|
|
requests shared locks (<link linkend="locking-tables">ACCESS SHARE</link>) on the
|
|
|
|
objects that the worker processes are going to dump later in order to
|
2013-03-24 16:27:20 +01:00
|
|
|
make sure that nobody deletes them and makes them go away while the dump is running.
|
|
|
|
If another client then requests an exclusive lock on a table, that lock will not be
|
2020-06-14 23:22:47 +02:00
|
|
|
granted but will be queued waiting for the shared lock of the leader process to be
|
2013-09-15 17:01:14 +02:00
|
|
|
released. Consequently any other access to the table will not be granted either and
|
2013-03-24 16:27:20 +01:00
|
|
|
will queue after the exclusive lock request. This includes the worker process trying
|
|
|
|
to dump the table. Without any precautions this would be a classic deadlock situation.
|
2017-10-09 03:44:17 +02:00
|
|
|
To detect this conflict, the <application>pg_dump</application> worker process requests another
|
|
|
|
shared lock using the <literal>NOWAIT</literal> option. If the worker process is not granted
|
2013-03-24 16:27:20 +01:00
|
|
|
this shared lock, somebody else must have requested an exclusive lock in the meantime
|
2017-10-09 03:44:17 +02:00
|
|
|
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
|
2013-03-24 16:27:20 +01:00
|
|
|
but to abort the dump.
|
|
|
|
</para>
|
|
|
|
<para>
|
2021-12-16 00:44:47 +01:00
|
|
|
To perform a parallel dump, the database server needs to support
|
2017-08-17 01:46:50 +02:00
|
|
|
synchronized snapshots, a feature that was introduced in
|
|
|
|
<productname>PostgreSQL</productname> 9.2 for primary servers and 10
|
|
|
|
for standbys. With this feature, database clients can ensure they see
|
|
|
|
the same data set even though they use different connections.
|
|
|
|
<command>pg_dump -j</command> uses multiple database connections; it
|
2020-06-14 23:22:47 +02:00
|
|
|
connects to the database once with the leader process and once again
|
2017-08-17 01:46:50 +02:00
|
|
|
for each worker job. Without the synchronized snapshot feature, the
|
|
|
|
different worker jobs wouldn't be guaranteed to see the same data in
|
|
|
|
each connection, which could lead to an inconsistent backup.
|
2013-03-24 16:27:20 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2003-02-13 05:54:16 +01:00
|
|
|
<varlistentry>
|
2019-09-03 14:25:26 +02:00
|
|
|
<term><option>-n <replaceable class="parameter">pattern</replaceable></option></term>
|
|
|
|
<term><option>--schema=<replaceable class="parameter">pattern</replaceable></option></term>
|
2003-02-13 05:54:16 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2006-10-10 01:36:59 +02:00
|
|
|
Dump only schemas matching <replaceable
|
2019-09-03 14:25:26 +02:00
|
|
|
class="parameter">pattern</replaceable>; this selects both the
|
2006-10-10 01:36:59 +02:00
|
|
|
schema itself, and all its contained objects. When this option is
|
|
|
|
not specified, all non-system schemas in the target database will be
|
|
|
|
dumped. Multiple schemas can be
|
2019-09-03 14:25:26 +02:00
|
|
|
selected by writing multiple <option>-n</option> switches. The
|
|
|
|
<replaceable class="parameter">pattern</replaceable> parameter is
|
2006-10-10 01:36:59 +02:00
|
|
|
interpreted as a pattern according to the same rules used by
|
Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs.
Use xreflabel attributes instead of endterm attributes to control the
appearance of links to subsections of SQL command reference pages.
This is simpler, it matches what we do elsewhere (e.g. for GUC variables),
and it doesn't draw "Unresolved ID reference" warnings from the PDF
toolchain.
Fix some places where the text was absolutely dependent on an <xref>
rendering exactly so, by using a <link> around the required text
instead. At least one of those spots had already been turned into
bad grammar by subsequent changes, and the whole idea is just too
fragile for my taste. <xref> does NOT have fixed output, don't write
as if it does.
Consistently include a page-level link in cross-man-page references,
because otherwise they are useless/nonsensical in man-page output.
Likewise, be consistent about mentioning "below" or "above" in same-page
references; we were doing that in about 90% of the cases, but now it's
100%.
Also get rid of another nonfunctional-in-PDF idea, of making
cross-references to functions by sticking ID tags on <row> constructs.
We can put the IDs on <indexterm>s instead --- which is probably not any
more sensible in abstract terms, but it works where the other doesn't.
(There is talk of attaching cross-reference IDs to most or all of
the docs' function descriptions, but for now I just fixed the two
that exist.)
Discussion: https://postgr.es/m/14480.1589154358@sss.pgh.pa.us
2020-05-11 20:15:49 +02:00
|
|
|
<application>psql</application>'s <literal>\d</literal> commands
|
2022-09-23 04:05:09 +02:00
|
|
|
(see <xref linkend="app-psql-patterns"/>),
|
2006-10-10 01:36:59 +02:00
|
|
|
so multiple schemas can also be selected by writing wildcard characters
|
|
|
|
in the pattern. When using wildcards, be careful to quote the pattern
|
2011-03-11 01:40:23 +01:00
|
|
|
if needed to prevent the shell from expanding the wildcards; see
|
Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs.
Use xreflabel attributes instead of endterm attributes to control the
appearance of links to subsections of SQL command reference pages.
This is simpler, it matches what we do elsewhere (e.g. for GUC variables),
and it doesn't draw "Unresolved ID reference" warnings from the PDF
toolchain.
Fix some places where the text was absolutely dependent on an <xref>
rendering exactly so, by using a <link> around the required text
instead. At least one of those spots had already been turned into
bad grammar by subsequent changes, and the whole idea is just too
fragile for my taste. <xref> does NOT have fixed output, don't write
as if it does.
Consistently include a page-level link in cross-man-page references,
because otherwise they are useless/nonsensical in man-page output.
Likewise, be consistent about mentioning "below" or "above" in same-page
references; we were doing that in about 90% of the cases, but now it's
100%.
Also get rid of another nonfunctional-in-PDF idea, of making
cross-references to functions by sticking ID tags on <row> constructs.
We can put the IDs on <indexterm>s instead --- which is probably not any
more sensible in abstract terms, but it works where the other doesn't.
(There is talk of attaching cross-reference IDs to most or all of
the docs' function descriptions, but for now I just fixed the two
that exist.)
Discussion: https://postgr.es/m/14480.1589154358@sss.pgh.pa.us
2020-05-11 20:15:49 +02:00
|
|
|
<xref linkend="pg-dump-examples"/> below.
|
2003-02-13 05:54:16 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<note>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
When <option>-n</option> is specified, <application>pg_dump</application>
|
2006-10-10 01:36:59 +02:00
|
|
|
makes no attempt to dump any other database objects that the selected
|
Update reference documentation on may/can/might:
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
2007-02-01 00:26:05 +01:00
|
|
|
schema(s) might depend upon. Therefore, there is no guarantee
|
2006-10-10 01:36:59 +02:00
|
|
|
that the results of a specific-schema dump can be successfully
|
|
|
|
restored by themselves into a clean database.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
|
|
|
|
<note>
|
|
|
|
<para>
|
2022-12-05 08:52:11 +01:00
|
|
|
Non-schema objects such as large objects are not dumped when <option>-n</option> is
|
|
|
|
specified. You can add large objects back to the dump with the
|
|
|
|
<option>--large-objects</option> switch.
|
2003-02-13 05:54:16 +01:00
|
|
|
</para>
|
|
|
|
</note>
|
2006-10-10 01:36:59 +02:00
|
|
|
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2019-09-03 14:25:26 +02:00
|
|
|
<term><option>-N <replaceable class="parameter">pattern</replaceable></option></term>
|
|
|
|
<term><option>--exclude-schema=<replaceable class="parameter">pattern</replaceable></option></term>
|
2006-10-10 01:36:59 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2019-09-03 14:25:26 +02:00
|
|
|
Do not dump any schemas matching <replaceable
|
|
|
|
class="parameter">pattern</replaceable>. The pattern is
|
2017-10-09 03:44:17 +02:00
|
|
|
interpreted according to the same rules as for <option>-n</option>.
|
|
|
|
<option>-N</option> can be given more than once to exclude schemas
|
2006-10-10 01:36:59 +02:00
|
|
|
matching any of several patterns.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
When both <option>-n</option> and <option>-N</option> are given, the behavior
|
|
|
|
is to dump just the schemas that match at least one <option>-n</option>
|
|
|
|
switch but no <option>-N</option> switches. If <option>-N</option> appears
|
|
|
|
without <option>-n</option>, then schemas matching <option>-N</option> are
|
2006-10-10 01:36:59 +02:00
|
|
|
excluded from what is otherwise a normal dump.
|
|
|
|
</para>
|
2003-02-13 05:54:16 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2001-03-05 19:42:57 +01:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-O</option></term>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>--no-owner</option></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-09-24 00:48:53 +02:00
|
|
|
Do not output commands to set
|
2005-01-04 04:58:16 +01:00
|
|
|
ownership of objects to match the original database.
|
|
|
|
By default, <application>pg_dump</application> issues
|
2017-10-09 03:44:17 +02:00
|
|
|
<command>ALTER OWNER</command> or
|
2005-01-04 04:58:16 +01:00
|
|
|
<command>SET SESSION AUTHORIZATION</command>
|
|
|
|
statements 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
|
2017-10-09 03:44:17 +02:00
|
|
|
that user ownership of all the objects, specify <option>-O</option>.
|
2001-08-22 22:23:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2021-01-13 19:30:04 +01:00
|
|
|
This option is ignored when emitting an archive (non-text) output
|
|
|
|
file. For the archive formats, you can specify the option when you
|
2001-08-22 22:23:24 +02:00
|
|
|
call <command>pg_restore</command>.
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-R</option></term>
|
|
|
|
<term><option>--no-reconnect</option></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-09-24 00:48:53 +02:00
|
|
|
This option is obsolete but still accepted for backwards
|
2005-01-04 04:58:16 +01:00
|
|
|
compatibility.
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-s</option></term>
|
|
|
|
<term><option>--schema-only</option></term>
|
1999-07-06 19:16:42 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
Dump only the object definitions (schema), not data.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
2011-12-14 15:23:17 +01:00
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
This option is the inverse of <option>--data-only</option>.
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
It is similar to, but for historical reasons not identical to,
|
|
|
|
specifying
|
2017-10-09 03:44:17 +02:00
|
|
|
<option>--section=pre-data --section=post-data</option>.
|
2011-12-14 15:23:17 +01:00
|
|
|
</para>
|
2011-12-17 01:09:38 +01:00
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
(Do not confuse this with the <option>--schema</option> option, which
|
|
|
|
uses the word <quote>schema</quote> in a different meaning.)
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
To exclude table data for only a subset of tables in the database,
|
2017-10-09 03:44:17 +02:00
|
|
|
see <option>--exclude-table-data</option>.
|
2011-12-17 01:09:38 +01:00
|
|
|
</para>
|
1999-07-06 19:16:42 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2001-03-05 19:42:57 +01:00
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-S <replaceable class="parameter">username</replaceable></option></term>
|
|
|
|
<term><option>--superuser=<replaceable class="parameter">username</replaceable></option></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2002-05-11 00:36:27 +02:00
|
|
|
Specify the superuser user name to use when disabling triggers.
|
2017-10-09 03:44:17 +02:00
|
|
|
This is relevant only if <option>--disable-triggers</option> is used.
|
2005-01-04 04:58:16 +01:00
|
|
|
(Usually, it's better to leave this out, and instead start the
|
|
|
|
resulting script as superuser.)
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2019-09-03 14:25:26 +02:00
|
|
|
<term><option>-t <replaceable class="parameter">pattern</replaceable></option></term>
|
|
|
|
<term><option>--table=<replaceable class="parameter">pattern</replaceable></option></term>
|
2001-03-05 19:42:57 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2015-07-03 00:13:34 +02:00
|
|
|
Dump only tables with names matching
|
2020-10-06 15:46:36 +02:00
|
|
|
<replaceable class="parameter">pattern</replaceable>. Multiple tables
|
2019-09-03 14:25:26 +02:00
|
|
|
can be selected by writing multiple <option>-t</option> switches. The
|
|
|
|
<replaceable class="parameter">pattern</replaceable> parameter is
|
2006-10-10 01:36:59 +02:00
|
|
|
interpreted as a pattern according to the same rules used by
|
Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs.
Use xreflabel attributes instead of endterm attributes to control the
appearance of links to subsections of SQL command reference pages.
This is simpler, it matches what we do elsewhere (e.g. for GUC variables),
and it doesn't draw "Unresolved ID reference" warnings from the PDF
toolchain.
Fix some places where the text was absolutely dependent on an <xref>
rendering exactly so, by using a <link> around the required text
instead. At least one of those spots had already been turned into
bad grammar by subsequent changes, and the whole idea is just too
fragile for my taste. <xref> does NOT have fixed output, don't write
as if it does.
Consistently include a page-level link in cross-man-page references,
because otherwise they are useless/nonsensical in man-page output.
Likewise, be consistent about mentioning "below" or "above" in same-page
references; we were doing that in about 90% of the cases, but now it's
100%.
Also get rid of another nonfunctional-in-PDF idea, of making
cross-references to functions by sticking ID tags on <row> constructs.
We can put the IDs on <indexterm>s instead --- which is probably not any
more sensible in abstract terms, but it works where the other doesn't.
(There is talk of attaching cross-reference IDs to most or all of
the docs' function descriptions, but for now I just fixed the two
that exist.)
Discussion: https://postgr.es/m/14480.1589154358@sss.pgh.pa.us
2020-05-11 20:15:49 +02:00
|
|
|
<application>psql</application>'s <literal>\d</literal> commands
|
2022-09-23 04:05:09 +02:00
|
|
|
(see <xref linkend="app-psql-patterns"/>),
|
2006-10-10 01:36:59 +02:00
|
|
|
so multiple tables can also be selected by writing wildcard characters
|
|
|
|
in the pattern. When using wildcards, be careful to quote the pattern
|
2011-03-11 01:40:23 +01:00
|
|
|
if needed to prevent the shell from expanding the wildcards; see
|
Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs.
Use xreflabel attributes instead of endterm attributes to control the
appearance of links to subsections of SQL command reference pages.
This is simpler, it matches what we do elsewhere (e.g. for GUC variables),
and it doesn't draw "Unresolved ID reference" warnings from the PDF
toolchain.
Fix some places where the text was absolutely dependent on an <xref>
rendering exactly so, by using a <link> around the required text
instead. At least one of those spots had already been turned into
bad grammar by subsequent changes, and the whole idea is just too
fragile for my taste. <xref> does NOT have fixed output, don't write
as if it does.
Consistently include a page-level link in cross-man-page references,
because otherwise they are useless/nonsensical in man-page output.
Likewise, be consistent about mentioning "below" or "above" in same-page
references; we were doing that in about 90% of the cases, but now it's
100%.
Also get rid of another nonfunctional-in-PDF idea, of making
cross-references to functions by sticking ID tags on <row> constructs.
We can put the IDs on <indexterm>s instead --- which is probably not any
more sensible in abstract terms, but it works where the other doesn't.
(There is talk of attaching cross-reference IDs to most or all of
the docs' function descriptions, but for now I just fixed the two
that exist.)
Discussion: https://postgr.es/m/14480.1589154358@sss.pgh.pa.us
2020-05-11 20:15:49 +02:00
|
|
|
<xref linkend="pg-dump-examples"/> below.
|
2003-02-13 05:54:16 +01:00
|
|
|
</para>
|
|
|
|
|
2020-10-06 15:46:36 +02:00
|
|
|
<para>
|
2020-10-06 15:50:03 +02:00
|
|
|
As well as tables, this option can be used to dump the definition of matching
|
|
|
|
views, materialized views, foreign tables, and sequences. It will not dump the
|
|
|
|
contents of views or materialized views, and the contents of foreign tables will
|
|
|
|
only be dumped if the corresponding foreign server is specified with
|
2020-10-06 15:46:36 +02:00
|
|
|
<option>--include-foreign-data</option>.
|
|
|
|
</para>
|
|
|
|
|
2006-08-01 20:05:04 +02:00
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
The <option>-n</option> and <option>-N</option> switches have no effect when
|
|
|
|
<option>-t</option> is used, because tables selected by <option>-t</option> will
|
2006-10-10 01:36:59 +02:00
|
|
|
be dumped regardless of those switches, and non-table objects will not
|
|
|
|
be dumped.
|
2006-08-01 20:05:04 +02:00
|
|
|
</para>
|
|
|
|
|
2003-02-13 05:54:16 +01:00
|
|
|
<note>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
When <option>-t</option> is specified, <application>pg_dump</application>
|
2006-10-10 01:36:59 +02:00
|
|
|
makes no attempt to dump any other database objects that the selected
|
Update reference documentation on may/can/might:
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
2007-02-01 00:26:05 +01:00
|
|
|
table(s) might depend upon. Therefore, there is no guarantee
|
2006-08-01 20:05:04 +02:00
|
|
|
that the results of a specific-table dump can be successfully
|
2003-02-13 05:54:16 +01:00
|
|
|
restored by themselves into a clean database.
|
|
|
|
</para>
|
|
|
|
</note>
|
2006-10-10 01:36:59 +02:00
|
|
|
|
2001-03-05 19:42:57 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2006-08-01 20:05:04 +02:00
|
|
|
<varlistentry>
|
2019-09-03 14:25:26 +02:00
|
|
|
<term><option>-T <replaceable class="parameter">pattern</replaceable></option></term>
|
|
|
|
<term><option>--exclude-table=<replaceable class="parameter">pattern</replaceable></option></term>
|
2006-08-01 20:05:04 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2019-09-03 14:25:26 +02:00
|
|
|
Do not dump any tables matching <replaceable
|
|
|
|
class="parameter">pattern</replaceable>. The pattern is
|
2017-10-09 03:44:17 +02:00
|
|
|
interpreted according to the same rules as for <option>-t</option>.
|
|
|
|
<option>-T</option> can be given more than once to exclude tables
|
2006-10-10 01:36:59 +02:00
|
|
|
matching any of several patterns.
|
2006-08-01 20:05:04 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
When both <option>-t</option> and <option>-T</option> are given, the behavior
|
|
|
|
is to dump just the tables that match at least one <option>-t</option>
|
|
|
|
switch but no <option>-T</option> switches. If <option>-T</option> appears
|
|
|
|
without <option>-t</option>, then tables matching <option>-T</option> are
|
2006-10-10 01:36:59 +02:00
|
|
|
excluded from what is otherwise a normal dump.
|
2006-08-01 20:05:04 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-v</option></term>
|
|
|
|
<term><option>--verbose</option></term>
|
1999-07-06 19:16:42 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
Specifies verbose mode. This will cause
|
|
|
|
<application>pg_dump</application> to output detailed object
|
2006-10-10 01:36:59 +02:00
|
|
|
comments and start/stop times to the dump file, and progress
|
2004-06-07 22:35:57 +02:00
|
|
|
messages to standard error.
|
2020-09-17 18:52:18 +02:00
|
|
|
Repeating the option causes additional debug-level messages
|
|
|
|
to appear on standard error.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2010-02-19 15:36:45 +01:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-V</option></term>
|
|
|
|
<term><option>--version</option></term>
|
2010-02-19 15:36:45 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Print the <application>pg_dump</application> version and exit.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-x</option></term>
|
|
|
|
<term><option>--no-privileges</option></term>
|
|
|
|
<term><option>--no-acl</option></term>
|
1999-07-06 19:16:42 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
Prevent dumping of access privileges (grant/revoke commands).
|
2001-08-22 22:23:24 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2008-07-20 20:43:30 +02:00
|
|
|
<varlistentry>
|
Switch pg_dump to use compression specifications
Compression specifications are currently used by pg_basebackup and
pg_receivewal, and are able to let the user control in an extended way
the method and level of compression used. As an effect of this commit,
pg_dump's -Z/--compress is now able to use more than just an integer, as
of the grammar "method[:detail]".
The method can be either "none" or "gzip", and can optionally take a
detail string. If the detail string is only an integer, it defines the
compression level. A comma-separated list of keywords can also be used
method allows for more options, the only keyword supported now is
"level".
The change is backward-compatible, hence specifying only an integer
leads to no compression for a level of 0 and gzip compression when the
level is greater than 0.
Most of the code changes are straight-forward, as pg_dump was relying on
an integer tracking the compression level to check for gzip or no
compression. These are changed to use a compression specification and
the algorithm stored in it.
As of this change, note that the dump format is not bumped because there
is no need yet to track the compression algorithm in the TOC entries.
Hence, we still rely on the compression level to make the difference
when reading them. This will be mandatory once a new compression method
is added, though.
In order to keep the code simpler when parsing the compression
specification, the code is changed so as pg_dump now fails hard when
using gzip on -Z/--compress without its support compiled, rather than
enforcing no compression without the user knowing about it except
through a warning. Like before this commit, archive and custom formats
are compressed by default when the code is compiled with gzip, and left
uncompressed without gzip.
Author: Georgios Kokolatos
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
|
|
|
<term><option>-Z <replaceable class="parameter">level</replaceable></option></term>
|
|
|
|
<term><option>-Z <replaceable class="parameter">method</replaceable></option>[:<replaceable>detail</replaceable>]</term>
|
|
|
|
<term><option>--compress=<replaceable class="parameter">level</replaceable></option></term>
|
|
|
|
<term><option>--compress=<replaceable class="parameter">method</replaceable></option>[:<replaceable>detail</replaceable>]</term>
|
2008-07-20 20:43:30 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
Switch pg_dump to use compression specifications
Compression specifications are currently used by pg_basebackup and
pg_receivewal, and are able to let the user control in an extended way
the method and level of compression used. As an effect of this commit,
pg_dump's -Z/--compress is now able to use more than just an integer, as
of the grammar "method[:detail]".
The method can be either "none" or "gzip", and can optionally take a
detail string. If the detail string is only an integer, it defines the
compression level. A comma-separated list of keywords can also be used
method allows for more options, the only keyword supported now is
"level".
The change is backward-compatible, hence specifying only an integer
leads to no compression for a level of 0 and gzip compression when the
level is greater than 0.
Most of the code changes are straight-forward, as pg_dump was relying on
an integer tracking the compression level to check for gzip or no
compression. These are changed to use a compression specification and
the algorithm stored in it.
As of this change, note that the dump format is not bumped because there
is no need yet to track the compression algorithm in the TOC entries.
Hence, we still rely on the compression level to make the difference
when reading them. This will be mandatory once a new compression method
is added, though.
In order to keep the code simpler when parsing the compression
specification, the code is changed so as pg_dump now fails hard when
using gzip on -Z/--compress without its support compiled, rather than
enforcing no compression without the user knowing about it except
through a warning. Like before this commit, archive and custom formats
are compressed by default when the code is compiled with gzip, and left
uncompressed without gzip.
Author: Georgios Kokolatos
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
|
|
|
Specify the compression method and/or the compression level to use.
|
2023-03-01 16:08:33 +01:00
|
|
|
The compression method can be set to <literal>gzip</literal>,
|
2023-04-05 21:38:04 +02:00
|
|
|
<literal>lz4</literal>, <literal>zstd</literal>,
|
|
|
|
or <literal>none</literal> for no compression.
|
Switch pg_dump to use compression specifications
Compression specifications are currently used by pg_basebackup and
pg_receivewal, and are able to let the user control in an extended way
the method and level of compression used. As an effect of this commit,
pg_dump's -Z/--compress is now able to use more than just an integer, as
of the grammar "method[:detail]".
The method can be either "none" or "gzip", and can optionally take a
detail string. If the detail string is only an integer, it defines the
compression level. A comma-separated list of keywords can also be used
method allows for more options, the only keyword supported now is
"level".
The change is backward-compatible, hence specifying only an integer
leads to no compression for a level of 0 and gzip compression when the
level is greater than 0.
Most of the code changes are straight-forward, as pg_dump was relying on
an integer tracking the compression level to check for gzip or no
compression. These are changed to use a compression specification and
the algorithm stored in it.
As of this change, note that the dump format is not bumped because there
is no need yet to track the compression algorithm in the TOC entries.
Hence, we still rely on the compression level to make the difference
when reading them. This will be mandatory once a new compression method
is added, though.
In order to keep the code simpler when parsing the compression
specification, the code is changed so as pg_dump now fails hard when
using gzip on -Z/--compress without its support compiled, rather than
enforcing no compression without the user knowing about it except
through a warning. Like before this commit, archive and custom formats
are compressed by default when the code is compiled with gzip, and left
uncompressed without gzip.
Author: Georgios Kokolatos
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
|
|
|
A compression detail string can optionally be specified. If the
|
|
|
|
detail string is an integer, it specifies the compression level.
|
|
|
|
Otherwise, it should be a comma-separated list of items, each of the
|
|
|
|
form <literal>keyword</literal> or <literal>keyword=value</literal>.
|
2023-05-22 12:26:40 +02:00
|
|
|
Currently, the supported keywords are <literal>level</literal> and
|
|
|
|
<literal>long</literal>.
|
Switch pg_dump to use compression specifications
Compression specifications are currently used by pg_basebackup and
pg_receivewal, and are able to let the user control in an extended way
the method and level of compression used. As an effect of this commit,
pg_dump's -Z/--compress is now able to use more than just an integer, as
of the grammar "method[:detail]".
The method can be either "none" or "gzip", and can optionally take a
detail string. If the detail string is only an integer, it defines the
compression level. A comma-separated list of keywords can also be used
method allows for more options, the only keyword supported now is
"level".
The change is backward-compatible, hence specifying only an integer
leads to no compression for a level of 0 and gzip compression when the
level is greater than 0.
Most of the code changes are straight-forward, as pg_dump was relying on
an integer tracking the compression level to check for gzip or no
compression. These are changed to use a compression specification and
the algorithm stored in it.
As of this change, note that the dump format is not bumped because there
is no need yet to track the compression algorithm in the TOC entries.
Hence, we still rely on the compression level to make the difference
when reading them. This will be mandatory once a new compression method
is added, though.
In order to keep the code simpler when parsing the compression
specification, the code is changed so as pg_dump now fails hard when
using gzip on -Z/--compress without its support compiled, rather than
enforcing no compression without the user knowing about it except
through a warning. Like before this commit, archive and custom formats
are compressed by default when the code is compiled with gzip, and left
uncompressed without gzip.
Author: Georgios Kokolatos
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
If no compression level is specified, the default compression
|
|
|
|
level will be used. If only a level is specified without mentioning
|
|
|
|
an algorithm, <literal>gzip</literal> compression will be used if
|
|
|
|
the level is greater than <literal>0</literal>, and no compression
|
|
|
|
will be used if the level is <literal>0</literal>.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2020-12-24 09:05:49 +01:00
|
|
|
For the custom and directory archive formats, this specifies compression of
|
Switch pg_dump to use compression specifications
Compression specifications are currently used by pg_basebackup and
pg_receivewal, and are able to let the user control in an extended way
the method and level of compression used. As an effect of this commit,
pg_dump's -Z/--compress is now able to use more than just an integer, as
of the grammar "method[:detail]".
The method can be either "none" or "gzip", and can optionally take a
detail string. If the detail string is only an integer, it defines the
compression level. A comma-separated list of keywords can also be used
method allows for more options, the only keyword supported now is
"level".
The change is backward-compatible, hence specifying only an integer
leads to no compression for a level of 0 and gzip compression when the
level is greater than 0.
Most of the code changes are straight-forward, as pg_dump was relying on
an integer tracking the compression level to check for gzip or no
compression. These are changed to use a compression specification and
the algorithm stored in it.
As of this change, note that the dump format is not bumped because there
is no need yet to track the compression algorithm in the TOC entries.
Hence, we still rely on the compression level to make the difference
when reading them. This will be mandatory once a new compression method
is added, though.
In order to keep the code simpler when parsing the compression
specification, the code is changed so as pg_dump now fails hard when
using gzip on -Z/--compress without its support compiled, rather than
enforcing no compression without the user knowing about it except
through a warning. Like before this commit, archive and custom formats
are compressed by default when the code is compiled with gzip, and left
uncompressed without gzip.
Author: Georgios Kokolatos
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
|
|
|
individual table-data segments, and the default is to compress using
|
|
|
|
<literal>gzip</literal> at a moderate level. For plain text output,
|
|
|
|
setting a nonzero compression level causes the entire output file to be compressed,
|
2023-04-05 21:38:04 +02:00
|
|
|
as though it had been fed through <application>gzip</application>,
|
|
|
|
<application>lz4</application>, or <application>zstd</application>;
|
|
|
|
but the default is not to compress.
|
2023-04-06 17:18:38 +02:00
|
|
|
With zstd compression, <literal>long</literal> mode may improve the
|
|
|
|
compression ratio, at the cost of increased memory use.
|
Switch pg_dump to use compression specifications
Compression specifications are currently used by pg_basebackup and
pg_receivewal, and are able to let the user control in an extended way
the method and level of compression used. As an effect of this commit,
pg_dump's -Z/--compress is now able to use more than just an integer, as
of the grammar "method[:detail]".
The method can be either "none" or "gzip", and can optionally take a
detail string. If the detail string is only an integer, it defines the
compression level. A comma-separated list of keywords can also be used
method allows for more options, the only keyword supported now is
"level".
The change is backward-compatible, hence specifying only an integer
leads to no compression for a level of 0 and gzip compression when the
level is greater than 0.
Most of the code changes are straight-forward, as pg_dump was relying on
an integer tracking the compression level to check for gzip or no
compression. These are changed to use a compression specification and
the algorithm stored in it.
As of this change, note that the dump format is not bumped because there
is no need yet to track the compression algorithm in the TOC entries.
Hence, we still rely on the compression level to make the difference
when reading them. This will be mandatory once a new compression method
is added, though.
In order to keep the code simpler when parsing the compression
specification, the code is changed so as pg_dump now fails hard when
using gzip on -Z/--compress without its support compiled, rather than
enforcing no compression without the user knowing about it except
through a warning. Like before this commit, archive and custom formats
are compressed by default when the code is compiled with gzip, and left
uncompressed without gzip.
Author: Georgios Kokolatos
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2008-08-26 02:03:15 +02:00
|
|
|
The tar archive format currently does not support compression at all.
|
2008-07-20 20:43:30 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2009-03-04 12:57:00 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--binary-upgrade</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
This option is for use by in-place upgrade utilities. Its use
|
|
|
|
for other purposes is not recommended or supported. The
|
|
|
|
behavior of the option may change in future releases without
|
|
|
|
notice.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2009-03-22 17:44:26 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--column-inserts</option></term>
|
|
|
|
<term><option>--attribute-inserts</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Dump data as <command>INSERT</command> commands with explicit
|
|
|
|
column names (<literal>INSERT INTO
|
|
|
|
<replaceable>table</replaceable>
|
|
|
|
(<replaceable>column</replaceable>, ...) VALUES
|
|
|
|
...</literal>). This will make restoration very slow; it is mainly
|
|
|
|
useful for making dumps that can be loaded into
|
|
|
|
non-<productname>PostgreSQL</productname> databases.
|
2022-07-21 20:55:23 +02:00
|
|
|
Any error during restoring will cause only rows that are part of the
|
2019-03-07 13:26:14 +01:00
|
|
|
problematic <command>INSERT</command> to be lost, rather than the
|
|
|
|
entire table contents.
|
2009-03-22 17:44:26 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2014-03-03 19:02:18 +01:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>--disable-dollar-quoting</option></term>
|
2001-08-22 22:23:24 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-03-23 23:06:08 +01:00
|
|
|
This option disables the use of dollar quoting for function bodies,
|
|
|
|
and forces them to be quoted using SQL standard string syntax.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
2008-07-20 20:43:30 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2001-03-05 19:42:57 +01:00
|
|
|
|
2002-05-11 00:36:27 +02:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>--disable-triggers</option></term>
|
2002-05-11 00:36:27 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2012-11-12 04:50:24 +01:00
|
|
|
This option is relevant only when creating a data-only dump.
|
2004-03-23 23:06:08 +01:00
|
|
|
It instructs <application>pg_dump</application> to include commands
|
|
|
|
to temporarily disable triggers on the target tables while
|
2022-07-21 20:55:23 +02:00
|
|
|
the data is restored. Use this if you have referential
|
2004-03-23 23:06:08 +01:00
|
|
|
integrity checks or other triggers on the tables that you
|
2022-07-21 20:55:23 +02:00
|
|
|
do not want to invoke during data restore.
|
2002-05-11 00:36:27 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
Presently, the commands emitted for <option>--disable-triggers</option>
|
2004-03-23 23:06:08 +01:00
|
|
|
must be done as superuser. So, you should also specify
|
2017-10-09 03:44:17 +02:00
|
|
|
a superuser name with <option>-S</option>, or preferably be careful to
|
2004-03-23 23:06:08 +01:00
|
|
|
start the resulting script as a superuser.
|
2002-05-11 00:36:27 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2021-01-13 19:30:04 +01:00
|
|
|
This option is ignored when emitting an archive (non-text) output
|
|
|
|
file. For the archive formats, you can specify the option when you
|
2002-05-11 00:36:27 +02:00
|
|
|
call <command>pg_restore</command>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
Code review for row security.
Buildfarm member tick identified an issue where the policies in the
relcache for a relation were were being replaced underneath a running
query, leading to segfaults while processing the policies to be added
to a query. Similar to how TupleDesc RuleLocks are handled, add in a
equalRSDesc() function to check if the policies have actually changed
and, if not, swap back the rsdesc field (using the original instead of
the temporairly built one; the whole structure is swapped and then
specific fields swapped back). This now passes a CLOBBER_CACHE_ALWAYS
for me and should resolve the buildfarm error.
In addition to addressing this, add a new chapter in Data Definition
under Privileges which explains row security and provides examples of
its usage, change \d to always list policies (even if row security is
disabled- but note that it is disabled, or enabled with no policies),
rework check_role_for_policy (it really didn't need the entire policy,
but it did need to be using has_privs_of_role()), and change the field
in pg_class to relrowsecurity from relhasrowsecurity, based on
Heikki's suggestion. Also from Heikki, only issue SET ROW_SECURITY in
pg_restore when talking to a 9.5+ server, list Bypass RLS in \du, and
document --enable-row-security options for pg_dump and pg_restore.
Lastly, fix a number of minor whitespace and typo issues from Heikki,
Dimitri, add a missing #include, per Peter E, fix a few minor
variable-assigned-but-not-used and resource leak issues from Coverity
and add tab completion for role attribute bypassrls as well.
2014-09-24 22:32:22 +02:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>--enable-row-security</option></term>
|
Code review for row security.
Buildfarm member tick identified an issue where the policies in the
relcache for a relation were were being replaced underneath a running
query, leading to segfaults while processing the policies to be added
to a query. Similar to how TupleDesc RuleLocks are handled, add in a
equalRSDesc() function to check if the policies have actually changed
and, if not, swap back the rsdesc field (using the original instead of
the temporairly built one; the whole structure is swapped and then
specific fields swapped back). This now passes a CLOBBER_CACHE_ALWAYS
for me and should resolve the buildfarm error.
In addition to addressing this, add a new chapter in Data Definition
under Privileges which explains row security and provides examples of
its usage, change \d to always list policies (even if row security is
disabled- but note that it is disabled, or enabled with no policies),
rework check_role_for_policy (it really didn't need the entire policy,
but it did need to be using has_privs_of_role()), and change the field
in pg_class to relrowsecurity from relhasrowsecurity, based on
Heikki's suggestion. Also from Heikki, only issue SET ROW_SECURITY in
pg_restore when talking to a 9.5+ server, list Bypass RLS in \du, and
document --enable-row-security options for pg_dump and pg_restore.
Lastly, fix a number of minor whitespace and typo issues from Heikki,
Dimitri, add a missing #include, per Peter E, fix a few minor
variable-assigned-but-not-used and resource leak issues from Coverity
and add tab completion for role attribute bypassrls as well.
2014-09-24 22:32:22 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
This option is relevant only when dumping the contents of a table
|
2015-09-18 02:56:58 +02:00
|
|
|
which has row security. By default, <application>pg_dump</application> will set
|
2017-11-23 15:39:47 +01:00
|
|
|
<xref linkend="guc-row-security"/> to off, to ensure
|
Code review for row security.
Buildfarm member tick identified an issue where the policies in the
relcache for a relation were were being replaced underneath a running
query, leading to segfaults while processing the policies to be added
to a query. Similar to how TupleDesc RuleLocks are handled, add in a
equalRSDesc() function to check if the policies have actually changed
and, if not, swap back the rsdesc field (using the original instead of
the temporairly built one; the whole structure is swapped and then
specific fields swapped back). This now passes a CLOBBER_CACHE_ALWAYS
for me and should resolve the buildfarm error.
In addition to addressing this, add a new chapter in Data Definition
under Privileges which explains row security and provides examples of
its usage, change \d to always list policies (even if row security is
disabled- but note that it is disabled, or enabled with no policies),
rework check_role_for_policy (it really didn't need the entire policy,
but it did need to be using has_privs_of_role()), and change the field
in pg_class to relrowsecurity from relhasrowsecurity, based on
Heikki's suggestion. Also from Heikki, only issue SET ROW_SECURITY in
pg_restore when talking to a 9.5+ server, list Bypass RLS in \du, and
document --enable-row-security options for pg_dump and pg_restore.
Lastly, fix a number of minor whitespace and typo issues from Heikki,
Dimitri, add a missing #include, per Peter E, fix a few minor
variable-assigned-but-not-used and resource leak issues from Coverity
and add tab completion for role attribute bypassrls as well.
2014-09-24 22:32:22 +02:00
|
|
|
that all data is dumped from the table. If the user does not have
|
|
|
|
sufficient privileges to bypass row security, then an error is thrown.
|
|
|
|
This parameter instructs <application>pg_dump</application> to set
|
2017-11-23 15:39:47 +01:00
|
|
|
<xref linkend="guc-row-security"/> to on instead, allowing the user
|
2015-09-18 02:56:58 +02:00
|
|
|
to dump the parts of the contents of the table that they have access to.
|
Code review for row security.
Buildfarm member tick identified an issue where the policies in the
relcache for a relation were were being replaced underneath a running
query, leading to segfaults while processing the policies to be added
to a query. Similar to how TupleDesc RuleLocks are handled, add in a
equalRSDesc() function to check if the policies have actually changed
and, if not, swap back the rsdesc field (using the original instead of
the temporairly built one; the whole structure is swapped and then
specific fields swapped back). This now passes a CLOBBER_CACHE_ALWAYS
for me and should resolve the buildfarm error.
In addition to addressing this, add a new chapter in Data Definition
under Privileges which explains row security and provides examples of
its usage, change \d to always list policies (even if row security is
disabled- but note that it is disabled, or enabled with no policies),
rework check_role_for_policy (it really didn't need the entire policy,
but it did need to be using has_privs_of_role()), and change the field
in pg_class to relrowsecurity from relhasrowsecurity, based on
Heikki's suggestion. Also from Heikki, only issue SET ROW_SECURITY in
pg_restore when talking to a 9.5+ server, list Bypass RLS in \du, and
document --enable-row-security options for pg_dump and pg_restore.
Lastly, fix a number of minor whitespace and typo issues from Heikki,
Dimitri, add a missing #include, per Peter E, fix a few minor
variable-assigned-but-not-used and resource leak issues from Coverity
and add tab completion for role attribute bypassrls as well.
2014-09-24 22:32:22 +02:00
|
|
|
</para>
|
|
|
|
|
2016-12-23 02:56:50 +01:00
|
|
|
<para>
|
|
|
|
Note that if you use this option currently, you probably also want
|
|
|
|
the dump be in <command>INSERT</command> format, as the
|
|
|
|
<command>COPY FROM</command> during restore does not support row security.
|
|
|
|
</para>
|
Code review for row security.
Buildfarm member tick identified an issue where the policies in the
relcache for a relation were were being replaced underneath a running
query, leading to segfaults while processing the policies to be added
to a query. Similar to how TupleDesc RuleLocks are handled, add in a
equalRSDesc() function to check if the policies have actually changed
and, if not, swap back the rsdesc field (using the original instead of
the temporairly built one; the whole structure is swapped and then
specific fields swapped back). This now passes a CLOBBER_CACHE_ALWAYS
for me and should resolve the buildfarm error.
In addition to addressing this, add a new chapter in Data Definition
under Privileges which explains row security and provides examples of
its usage, change \d to always list policies (even if row security is
disabled- but note that it is disabled, or enabled with no policies),
rework check_role_for_policy (it really didn't need the entire policy,
but it did need to be using has_privs_of_role()), and change the field
in pg_class to relrowsecurity from relhasrowsecurity, based on
Heikki's suggestion. Also from Heikki, only issue SET ROW_SECURITY in
pg_restore when talking to a 9.5+ server, list Bypass RLS in \du, and
document --enable-row-security options for pg_dump and pg_restore.
Lastly, fix a number of minor whitespace and typo issues from Heikki,
Dimitri, add a missing #include, per Peter E, fix a few minor
variable-assigned-but-not-used and resource leak issues from Coverity
and add tab completion for role attribute bypassrls as well.
2014-09-24 22:32:22 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2023-03-14 21:09:03 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--exclude-table-and-children=<replaceable class="parameter">pattern</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
This is the same as
|
|
|
|
the <option>-T</option>/<option>--exclude-table</option> option,
|
|
|
|
except that it also excludes any partitions or inheritance child
|
|
|
|
tables of the table(s) matching the
|
|
|
|
<replaceable class="parameter">pattern</replaceable>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2011-12-14 15:23:17 +01:00
|
|
|
<varlistentry>
|
2019-09-03 14:25:26 +02:00
|
|
|
<term><option>--exclude-table-data=<replaceable class="parameter">pattern</replaceable></option></term>
|
2011-12-14 15:23:17 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2019-09-03 14:25:26 +02:00
|
|
|
Do not dump data for any tables matching <replaceable
|
|
|
|
class="parameter">pattern</replaceable>. The pattern is
|
2017-10-09 03:44:17 +02:00
|
|
|
interpreted according to the same rules as for <option>-t</option>.
|
|
|
|
<option>--exclude-table-data</option> can be given more than once to
|
2011-12-14 15:23:17 +01:00
|
|
|
exclude tables matching any of several patterns. This option is
|
|
|
|
useful when you need the definition of a particular table even
|
|
|
|
though you do not need the data in it.
|
|
|
|
</para>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
To exclude data for all tables in the database, see <option>--schema-only</option>.
|
2011-12-14 22:49:20 +01:00
|
|
|
</para>
|
2011-12-14 15:23:17 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2023-03-14 21:09:03 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--exclude-table-data-and-children=<replaceable class="parameter">pattern</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
This is the same as the <option>--exclude-table-data</option> option,
|
|
|
|
except that it also excludes data of any partitions or inheritance
|
|
|
|
child tables of the table(s) matching the
|
|
|
|
<replaceable class="parameter">pattern</replaceable>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2019-02-18 13:22:00 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--extra-float-digits=<replaceable class="parameter">ndigits</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2019-07-13 07:43:29 +02:00
|
|
|
Use the specified value of <option>extra_float_digits</option> when dumping
|
2019-02-18 13:22:00 +01:00
|
|
|
floating-point data, instead of the maximum available precision.
|
|
|
|
Routine dumps made for backup purposes should not use this option.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
Read include/exclude commands for dump/restore from file
When there is a need to filter multiple tables with include and/or exclude
options it's quite possible to run into the limitations of the commandline.
This adds a --filter=FILENAME feature to pg_dump, pg_dumpall and pg_restore
which is used to supply a file containing object exclude/include commands
which work just like their commandline counterparts. The format of the file
is one command per row like:
<command> <object> <objectpattern>
<command> can be "include" or "exclude", <object> can be table_data, index
table_data_and_children, database, extension, foreign_data, function, table
schema, table_and_children or trigger.
This patch has gone through many revisions and design changes over a long
period of time, the list of reviewers reflect reviewers of some version of
the patch, not necessarily the final version.
Patch by Pavel Stehule with some additional hacking by me.
Author: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Reviewed-by: Erik Rijkers <er@xs4all.nl>
Discussion: https://postgr.es/m/CAFj8pRB10wvW0CC9Xq=1XDs=zCQxer3cbLcNZa+qiX4cUH-G_A@mail.gmail.com
2023-11-29 14:56:24 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--filter=<replaceable class="parameter">filename</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Specify a filename from which to read patterns for objects to include
|
|
|
|
or exclude from the dump. The patterns are interpreted according to the
|
|
|
|
same rules as the corresponding options:
|
|
|
|
<option>-t</option>/<option>--table</option>,
|
|
|
|
<option>--table-and-children</option>,
|
|
|
|
<option>--exclude-table-and-children</option> or
|
|
|
|
<option>-T</option> for tables,
|
|
|
|
<option>-n</option>/<option>--schema</option> for schemas,
|
|
|
|
<option>--include-foreign-data</option> for data on foreign servers and
|
|
|
|
<option>--exclude-table-data</option>,
|
|
|
|
<option>--exclude-table-data-and-children</option> for table data,
|
|
|
|
<option>-e</option>/<option>--extension</option> for extensions.
|
|
|
|
To read from <literal>STDIN</literal>, use <filename>-</filename> as the
|
|
|
|
filename. The <option>--filter</option> option can be specified in
|
|
|
|
conjunction with the above listed options for including or excluding
|
|
|
|
objects, and can also be specified more than once for multiple filter
|
|
|
|
files.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The file lists one object pattern per row, with the following format:
|
|
|
|
<synopsis>
|
|
|
|
{ include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } <replaceable class="parameter">PATTERN</replaceable>
|
|
|
|
</synopsis>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The first keyword specifies whether the objects matched by the pattern
|
|
|
|
are to be included or excluded. The second keyword specifies the type
|
|
|
|
of object to be filtered using the pattern:
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<literal>extension</literal>: extensions, works like the
|
|
|
|
<option>--extension</option> option. This keyword can only be
|
|
|
|
used with the <literal>include</literal> keyword.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<literal>foreign_data</literal>: data on foreign servers, works like
|
|
|
|
the <option>--include-foreign-data</option> option. This keyword can
|
|
|
|
only be used with the <literal>include</literal> keyword.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<literal>table</literal>: tables, works like the
|
|
|
|
<option>-t</option>/<option>--table</option> option.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<literal>table_and_children</literal>: tables including any partitions
|
|
|
|
or inheritance child tables, works like the
|
|
|
|
<option>--table-and-children</option> option.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<literal>table_data</literal>: table data of any tables matching
|
|
|
|
<replaceable>pattern</replaceable>, works like the
|
|
|
|
<option>--exclude-table-data</option> option. This keyword can only
|
|
|
|
be used with the <literal>exclude</literal> keyword.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<literal>table_data_and_children</literal>: table data of any tables
|
|
|
|
matching <replaceable>pattern</replaceable> as well as any partitions
|
|
|
|
or inheritance children of the table(s), works like the
|
|
|
|
<option>--exclude-table-data-and-children</option> option. This
|
|
|
|
keyword can only be used with the <literal>exclude</literal> keyword.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<literal>schema</literal>: schemas, works like the
|
|
|
|
<option>-n</option>/<option>--schema</option> option.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Lines starting with <literal>#</literal> are considered comments and
|
|
|
|
ignored. Comments can be placed after an object pattern row as well.
|
|
|
|
Blank lines are also ignored. See <xref linkend="app-psql-patterns"/>
|
|
|
|
for how to perform quoting in patterns.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Example files are listed below in the <xref linkend="pg-dump-examples"/>
|
|
|
|
section.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2014-07-15 20:34:33 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--if-exists</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2023-09-29 19:13:54 +02:00
|
|
|
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
|
|
|
|
in <option>--clean</option> mode. This suppresses <quote>does not
|
|
|
|
exist</quote> errors that might otherwise be reported. This
|
|
|
|
option is not valid unless <option>--clean</option> is also
|
|
|
|
specified.
|
2014-07-15 20:34:33 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2020-03-25 17:19:31 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--include-foreign-data=<replaceable class="parameter">foreignserver</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Dump the data for any foreign table with a foreign server
|
|
|
|
matching <replaceable class="parameter">foreignserver</replaceable>
|
|
|
|
pattern. Multiple foreign servers can be selected by writing multiple
|
|
|
|
<option>--include-foreign-data</option> switches.
|
|
|
|
Also, the <replaceable class="parameter">foreignserver</replaceable> parameter is
|
|
|
|
interpreted as a pattern according to the same rules used by
|
Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs.
Use xreflabel attributes instead of endterm attributes to control the
appearance of links to subsections of SQL command reference pages.
This is simpler, it matches what we do elsewhere (e.g. for GUC variables),
and it doesn't draw "Unresolved ID reference" warnings from the PDF
toolchain.
Fix some places where the text was absolutely dependent on an <xref>
rendering exactly so, by using a <link> around the required text
instead. At least one of those spots had already been turned into
bad grammar by subsequent changes, and the whole idea is just too
fragile for my taste. <xref> does NOT have fixed output, don't write
as if it does.
Consistently include a page-level link in cross-man-page references,
because otherwise they are useless/nonsensical in man-page output.
Likewise, be consistent about mentioning "below" or "above" in same-page
references; we were doing that in about 90% of the cases, but now it's
100%.
Also get rid of another nonfunctional-in-PDF idea, of making
cross-references to functions by sticking ID tags on <row> constructs.
We can put the IDs on <indexterm>s instead --- which is probably not any
more sensible in abstract terms, but it works where the other doesn't.
(There is talk of attaching cross-reference IDs to most or all of
the docs' function descriptions, but for now I just fixed the two
that exist.)
Discussion: https://postgr.es/m/14480.1589154358@sss.pgh.pa.us
2020-05-11 20:15:49 +02:00
|
|
|
<application>psql</application>'s <literal>\d</literal> commands
|
2022-09-23 04:05:09 +02:00
|
|
|
(see <xref linkend="app-psql-patterns"/>),
|
2020-03-25 17:19:31 +01:00
|
|
|
so multiple foreign servers can also be selected by writing wildcard characters
|
|
|
|
in the pattern. When using wildcards, be careful to quote the pattern
|
|
|
|
if needed to prevent the shell from expanding the wildcards; see
|
Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs.
Use xreflabel attributes instead of endterm attributes to control the
appearance of links to subsections of SQL command reference pages.
This is simpler, it matches what we do elsewhere (e.g. for GUC variables),
and it doesn't draw "Unresolved ID reference" warnings from the PDF
toolchain.
Fix some places where the text was absolutely dependent on an <xref>
rendering exactly so, by using a <link> around the required text
instead. At least one of those spots had already been turned into
bad grammar by subsequent changes, and the whole idea is just too
fragile for my taste. <xref> does NOT have fixed output, don't write
as if it does.
Consistently include a page-level link in cross-man-page references,
because otherwise they are useless/nonsensical in man-page output.
Likewise, be consistent about mentioning "below" or "above" in same-page
references; we were doing that in about 90% of the cases, but now it's
100%.
Also get rid of another nonfunctional-in-PDF idea, of making
cross-references to functions by sticking ID tags on <row> constructs.
We can put the IDs on <indexterm>s instead --- which is probably not any
more sensible in abstract terms, but it works where the other doesn't.
(There is talk of attaching cross-reference IDs to most or all of
the docs' function descriptions, but for now I just fixed the two
that exist.)
Discussion: https://postgr.es/m/14480.1589154358@sss.pgh.pa.us
2020-05-11 20:15:49 +02:00
|
|
|
<xref linkend="pg-dump-examples"/> below.
|
2020-03-25 17:19:31 +01:00
|
|
|
The only exception is that an empty pattern is disallowed.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
When <option>--include-foreign-data</option> is specified,
|
|
|
|
<application>pg_dump</application> does not check that the foreign
|
2020-07-05 15:37:57 +02:00
|
|
|
table is writable. Therefore, there is no guarantee that the
|
2020-03-25 17:19:31 +01:00
|
|
|
results of a foreign table dump can be successfully restored.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2011-05-25 20:53:26 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--inserts</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Dump data as <command>INSERT</command> commands (rather
|
|
|
|
than <command>COPY</command>). This will make restoration very slow;
|
|
|
|
it is mainly useful for making dumps that can be loaded into
|
|
|
|
non-<productname>PostgreSQL</productname> databases.
|
2022-07-21 20:55:23 +02:00
|
|
|
Any error during restoring will cause only rows that are part of the
|
2019-03-07 13:26:14 +01:00
|
|
|
problematic <command>INSERT</command> to be lost, rather than the
|
|
|
|
entire table contents. Note that the restore might fail altogether if
|
|
|
|
you have rearranged column order. The
|
|
|
|
<option>--column-inserts</option> option is safe against column order
|
|
|
|
changes, though even slower.
|
2011-05-25 20:53:26 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2018-06-04 21:03:15 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--load-via-partition-root</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2018-09-24 00:34:18 +02:00
|
|
|
When dumping data for a table partition, make
|
|
|
|
the <command>COPY</command> or <command>INSERT</command> statements
|
|
|
|
target the root of the partitioning hierarchy that contains it, rather
|
|
|
|
than the partition itself. This causes the appropriate partition to
|
|
|
|
be re-determined for each row when the data is loaded. This may be
|
2022-07-21 20:55:23 +02:00
|
|
|
useful when restoring data on a server where rows do not always fall
|
2018-09-24 00:34:18 +02:00
|
|
|
into the same partitions as they did on the original server. That
|
|
|
|
could happen, for example, if the partitioning column is of type text
|
|
|
|
and the two systems have different definitions of the collation used
|
|
|
|
to sort the partitioning column.
|
|
|
|
</para>
|
2018-06-04 21:03:15 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2018-06-08 05:36:04 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--lock-wait-timeout=<replaceable class="parameter">timeout</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Do not wait forever to acquire shared table locks at the beginning of
|
|
|
|
the dump. Instead fail if unable to lock a table within the specified
|
|
|
|
<replaceable class="parameter">timeout</replaceable>. The timeout may be
|
|
|
|
specified in any of the formats accepted by <command>SET
|
|
|
|
statement_timeout</command>. (Allowed formats vary depending on the server
|
|
|
|
version you are dumping from, but an integer number of milliseconds
|
|
|
|
is accepted by all versions.)
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
Support --no-comments in pg_dump, pg_dumpall, pg_restore.
We have switches already to suppress other subsidiary object properties,
such as ACLs, security labels, ownership, and tablespaces, so just on
the grounds of symmetry we should allow suppressing comments as well.
Also, commit 0d4e6ed30 added a positive reason to have this feature,
i.e. to allow obtaining the old behavior of selective pg_restore should
anyone desire that.
Recent commits have removed the cases where pg_dump emitted comments on
built-in objects that the restoring user might not have privileges to
comment on, so the original primary motivation for this feature is gone,
but it still seems at least somewhat useful in its own right.
Robins Tharakan, reviewed by Fabrízio Mello
Discussion: https://postgr.es/m/CAEP4nAx22Z4ch74oJGzr5RyyjcyUSbpiFLyeYXX8pehfou92ug@mail.gmail.com
2018-01-25 21:27:24 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--no-comments</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Do not dump comments.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2017-05-12 15:15:40 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--no-publications</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Do not dump publications.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2017-01-19 18:00:00 +01:00
|
|
|
<varlistentry>
|
2017-03-23 13:36:36 +01:00
|
|
|
<term><option>--no-security-labels</option></term>
|
2017-01-19 18:00:00 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-03-23 13:36:36 +01:00
|
|
|
Do not dump security labels.
|
2017-01-19 18:00:00 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2017-05-09 16:58:06 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--no-subscriptions</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Do not dump subscriptions.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2017-06-14 17:09:33 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--no-sync</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
By default, <command>pg_dump</command> will wait for all files
|
|
|
|
to be written safely to disk. This option causes
|
|
|
|
<command>pg_dump</command> to return without waiting, which is
|
|
|
|
faster, but means that a subsequent operating system crash can leave
|
|
|
|
the dump corrupt. Generally, this option is useful for testing
|
|
|
|
but should not be used when dumping data from production installation.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2013-03-24 16:27:20 +01:00
|
|
|
<varlistentry>
|
2022-01-17 06:51:46 +01:00
|
|
|
<term><option>--no-table-access-method</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Do not output commands to select table access methods.
|
|
|
|
With this option, all objects will be created with whichever
|
|
|
|
table access method is the default during restore.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This option is ignored when emitting an archive (non-text) output
|
|
|
|
file. For the archive formats, you can specify the option when you
|
|
|
|
call <command>pg_restore</command>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2008-07-20 20:43:30 +02:00
|
|
|
<term><option>--no-tablespaces</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Do not output commands to select tablespaces.
|
|
|
|
With this option, all objects will be created in whichever
|
|
|
|
tablespace is the default during restore.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2021-01-13 19:30:04 +01:00
|
|
|
This option is ignored when emitting an archive (non-text) output
|
|
|
|
file. For the archive formats, you can specify the option when you
|
2008-07-20 20:43:30 +02:00
|
|
|
call <command>pg_restore</command>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2021-03-22 15:34:10 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--no-toast-compression</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Do not output commands to set <acronym>TOAST</acronym> compression
|
|
|
|
methods.
|
2021-05-27 19:24:24 +02:00
|
|
|
With this option, all columns will be restored with the default
|
|
|
|
compression setting.
|
2021-03-22 15:34:10 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2010-12-24 13:11:11 +01:00
|
|
|
<varlistentry>
|
2011-05-25 20:53:26 +02:00
|
|
|
<term><option>--no-unlogged-table-data</option></term>
|
2010-12-24 13:11:11 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2022-04-07 16:13:23 +02:00
|
|
|
Do not dump the contents of unlogged tables and sequences. This
|
|
|
|
option has no effect on whether or not the table and sequence
|
|
|
|
definitions (schema) are dumped; it only suppresses dumping the table
|
|
|
|
and sequence data. Data in unlogged tables and sequences
|
2013-01-25 09:44:14 +01:00
|
|
|
is always excluded when dumping from a standby server.
|
2010-12-24 13:11:11 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2018-07-13 03:57:03 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--on-conflict-do-nothing</option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Add <literal>ON CONFLICT DO NOTHING</literal> to
|
|
|
|
<command>INSERT</command> commands.
|
2019-03-07 13:26:14 +01:00
|
|
|
This option is not valid unless <option>--inserts</option>,
|
|
|
|
<option>--column-inserts</option> or
|
|
|
|
<option>--rows-per-insert</option> is also specified.
|
2018-07-13 03:57:03 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2004-03-23 23:06:08 +01:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>--quote-all-identifiers</option></term>
|
2004-03-23 23:06:08 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2016-05-20 20:59:47 +02:00
|
|
|
Force quoting of all identifiers. This option is recommended when
|
2017-10-09 03:44:17 +02:00
|
|
|
dumping a database from a server whose <productname>PostgreSQL</productname>
|
|
|
|
major version is different from <application>pg_dump</application>'s, or when
|
2016-05-20 20:59:47 +02:00
|
|
|
the output is intended to be loaded into a server of a different
|
2017-10-09 03:44:17 +02:00
|
|
|
major version. By default, <application>pg_dump</application> quotes only
|
2016-05-20 20:59:47 +02:00
|
|
|
identifiers that are reserved words in its own major version.
|
|
|
|
This sometimes results in compatibility issues when dealing with
|
|
|
|
servers of other versions that may have slightly different sets
|
2017-10-09 03:44:17 +02:00
|
|
|
of reserved words. Using <option>--quote-all-identifiers</option> prevents
|
2016-05-20 20:59:47 +02:00
|
|
|
such issues, at the price of a harder-to-read dump script.
|
2004-03-23 23:06:08 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2010-02-19 15:36:45 +01:00
|
|
|
|
2019-03-07 13:26:14 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--rows-per-insert=<replaceable class="parameter">nrows</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Dump data as <command>INSERT</command> commands (rather than
|
|
|
|
<command>COPY</command>). Controls the maximum number of rows per
|
|
|
|
<command>INSERT</command> command. The value specified must be a
|
2022-07-21 20:55:23 +02:00
|
|
|
number greater than zero. Any error during restoring will cause only
|
2019-03-07 13:26:14 +01:00
|
|
|
rows that are part of the problematic <command>INSERT</command> to be
|
|
|
|
lost, rather than the entire table contents.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2012-05-20 00:15:55 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--section=<replaceable class="parameter">sectionname</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
Only dump the named section. The section name can be
|
2017-10-09 03:44:17 +02:00
|
|
|
<option>pre-data</option>, <option>data</option>, or <option>post-data</option>.
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
This option can be specified more than once to select multiple
|
|
|
|
sections. The default is to dump all sections.
|
2012-05-20 00:15:55 +02:00
|
|
|
</para>
|
|
|
|
<para>
|
2012-10-26 18:12:42 +02:00
|
|
|
The data section contains actual table data, large-object
|
|
|
|
contents, and sequence values.
|
|
|
|
Post-data items include definitions of indexes, triggers, rules,
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
and constraints other than validated check constraints.
|
2012-10-26 18:12:42 +02:00
|
|
|
Pre-data items include all other data definition items.
|
2012-05-20 00:15:55 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2010-12-29 12:48:53 +01:00
|
|
|
<varlistentry>
|
2011-05-25 20:53:26 +02:00
|
|
|
<term><option>--serializable-deferrable</option></term>
|
2010-12-29 12:48:53 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2011-05-25 20:53:26 +02:00
|
|
|
Use a <literal>serializable</literal> transaction for the dump, to
|
|
|
|
ensure that the snapshot used is consistent with later database
|
|
|
|
states; but do this by waiting for a point in the transaction stream
|
|
|
|
at which no anomalies can be present, so that there isn't a risk of
|
|
|
|
the dump failing or causing other transactions to roll back with a
|
2017-11-23 15:39:47 +01:00
|
|
|
<literal>serialization_failure</literal>. See <xref linkend="mvcc"/>
|
2011-05-25 20:53:26 +02:00
|
|
|
for more information about transaction isolation and concurrency
|
|
|
|
control.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This option is not beneficial for a dump which is intended only for
|
|
|
|
disaster recovery. It could be useful for a dump used to load a
|
|
|
|
copy of the database for reporting or other read-only load sharing
|
|
|
|
while the original database continues to be updated. Without it the
|
|
|
|
dump may reflect a state which is not consistent with any serial
|
|
|
|
execution of the transactions eventually committed. For example, if
|
|
|
|
batch processing techniques are used, a batch may show as closed in
|
|
|
|
the dump without all of the items which are in the batch appearing.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This option will make no difference if there are no read-write
|
|
|
|
transactions active when pg_dump is started. If read-write
|
|
|
|
transactions are active, the start of the dump may be delayed for an
|
|
|
|
indeterminate length of time. Once running, performance with or
|
|
|
|
without the switch is the same.
|
2010-12-29 12:48:53 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2015-09-18 02:56:58 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--snapshot=<replaceable class="parameter">snapshotname</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Use the specified synchronized snapshot when making a dump of the
|
|
|
|
database (see
|
2017-11-23 15:39:47 +01:00
|
|
|
<xref linkend="functions-snapshot-synchronization-table"/> for more
|
2015-09-18 02:56:58 +02:00
|
|
|
details).
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
This option is useful when needing to synchronize the dump with
|
2017-11-23 15:39:47 +01:00
|
|
|
a logical replication slot (see <xref linkend="logicaldecoding"/>)
|
2015-09-18 02:56:58 +02:00
|
|
|
or with a concurrent session.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
In the case of a parallel dump, the snapshot name defined by this
|
|
|
|
option is used rather than taking a new snapshot.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2016-07-07 03:09:26 +02:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>--strict-names</option></term>
|
2016-07-07 03:09:26 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
Add support for --extension in pg_dump
When specified, only extensions matching the given pattern are included
in dumps. Similarly to --table and --schema, when --strict-names is
used, a perfect match is required. Also, like the two other options,
this new option offers no guarantee that dependent objects have been
dumped, so a restore may fail on a clean database.
Tests are added in test_pg_dump/, checking after a set of positive and
negative cases, with or without an extension's contents added to the
dump generated.
Author: Guillaume Lelarge
Reviewed-by: David Fetter, Tom Lane, Michael Paquier, Asif Rehman,
Julien Rouhaud
Discussion: https://postgr.es/m/CAECtzeXOt4cnMU5+XMZzxBPJ_wu76pNy6HZKPRBL-j7yj1E4+g@mail.gmail.com
2021-03-31 02:12:34 +02:00
|
|
|
Require that each
|
|
|
|
extension (<option>-e</option>/<option>--extension</option>),
|
|
|
|
schema (<option>-n</option>/<option>--schema</option>) and
|
2023-03-14 21:09:03 +01:00
|
|
|
table (<option>-t</option>/<option>--table</option>) pattern
|
Add support for --extension in pg_dump
When specified, only extensions matching the given pattern are included
in dumps. Similarly to --table and --schema, when --strict-names is
used, a perfect match is required. Also, like the two other options,
this new option offers no guarantee that dependent objects have been
dumped, so a restore may fail on a clean database.
Tests are added in test_pg_dump/, checking after a set of positive and
negative cases, with or without an extension's contents added to the
dump generated.
Author: Guillaume Lelarge
Reviewed-by: David Fetter, Tom Lane, Michael Paquier, Asif Rehman,
Julien Rouhaud
Discussion: https://postgr.es/m/CAECtzeXOt4cnMU5+XMZzxBPJ_wu76pNy6HZKPRBL-j7yj1E4+g@mail.gmail.com
2021-03-31 02:12:34 +02:00
|
|
|
match at least one extension/schema/table in the database to be dumped.
|
Read include/exclude commands for dump/restore from file
When there is a need to filter multiple tables with include and/or exclude
options it's quite possible to run into the limitations of the commandline.
This adds a --filter=FILENAME feature to pg_dump, pg_dumpall and pg_restore
which is used to supply a file containing object exclude/include commands
which work just like their commandline counterparts. The format of the file
is one command per row like:
<command> <object> <objectpattern>
<command> can be "include" or "exclude", <object> can be table_data, index
table_data_and_children, database, extension, foreign_data, function, table
schema, table_and_children or trigger.
This patch has gone through many revisions and design changes over a long
period of time, the list of reviewers reflect reviewers of some version of
the patch, not necessarily the final version.
Patch by Pavel Stehule with some additional hacking by me.
Author: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Reviewed-by: Erik Rijkers <er@xs4all.nl>
Discussion: https://postgr.es/m/CAFj8pRB10wvW0CC9Xq=1XDs=zCQxer3cbLcNZa+qiX4cUH-G_A@mail.gmail.com
2023-11-29 14:56:24 +01:00
|
|
|
This also applies to filters used with <option>--filter</option>.
|
2023-03-14 21:09:03 +01:00
|
|
|
Note that if none of the extension/schema/table patterns find
|
2016-07-07 03:09:26 +02:00
|
|
|
matches, <application>pg_dump</application> will generate an error
|
|
|
|
even without <option>--strict-names</option>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
This option has no effect
|
|
|
|
on <option>-N</option>/<option>--exclude-schema</option>,
|
|
|
|
<option>-T</option>/<option>--exclude-table</option>,
|
|
|
|
or <option>--exclude-table-data</option>. An exclude pattern failing
|
|
|
|
to match any objects is not considered an error.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
Allow using syncfs() in frontend utilities.
This commit allows specifying a --sync-method in several frontend
utilities that must synchronize many files to disk (initdb,
pg_basebackup, pg_checksums, pg_dump, pg_rewind, and pg_upgrade).
On Linux, users can specify "syncfs" to synchronize the relevant
file systems instead of calling fsync() for every single file. In
many cases, using syncfs() is much faster.
As with recovery_init_sync_method, this new option comes with some
caveats. The descriptions of these caveats have been moved to a
new appendix section in the documentation.
Co-authored-by: Justin Pryzby
Reviewed-by: Michael Paquier, Thomas Munro, Robert Haas, Justin Pryzby
Discussion: https://postgr.es/m/20210930004340.GM831%40telsasoft.com
2023-09-07 01:27:16 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
2023-10-04 21:40:50 +02:00
|
|
|
<term><option>--sync-method=<replaceable class="parameter">method</replaceable></option></term>
|
Allow using syncfs() in frontend utilities.
This commit allows specifying a --sync-method in several frontend
utilities that must synchronize many files to disk (initdb,
pg_basebackup, pg_checksums, pg_dump, pg_rewind, and pg_upgrade).
On Linux, users can specify "syncfs" to synchronize the relevant
file systems instead of calling fsync() for every single file. In
many cases, using syncfs() is much faster.
As with recovery_init_sync_method, this new option comes with some
caveats. The descriptions of these caveats have been moved to a
new appendix section in the documentation.
Co-authored-by: Justin Pryzby
Reviewed-by: Michael Paquier, Thomas Munro, Robert Haas, Justin Pryzby
Discussion: https://postgr.es/m/20210930004340.GM831%40telsasoft.com
2023-09-07 01:27:16 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
When set to <literal>fsync</literal>, which is the default,
|
|
|
|
<command>pg_dump --format=directory</command> will recursively open and
|
|
|
|
synchronize all files in the archive directory.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
On Linux, <literal>syncfs</literal> may be used instead to ask the
|
|
|
|
operating system to synchronize the whole file system that contains the
|
|
|
|
archive directory. See <xref linkend="syncfs"/> for more information
|
|
|
|
about using <function>syncfs()</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
This option has no effect when <option>--no-sync</option> is used or
|
|
|
|
<option>--format</option> is not set to <literal>directory</literal>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2016-07-07 03:09:26 +02:00
|
|
|
|
2023-03-14 21:09:03 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>--table-and-children=<replaceable class="parameter">pattern</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
This is the same as
|
|
|
|
the <option>-t</option>/<option>--table</option> option,
|
|
|
|
except that it also includes any partitions or inheritance child
|
|
|
|
tables of the table(s) matching the
|
|
|
|
<replaceable class="parameter">pattern</replaceable>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2010-07-22 03:22:35 +02:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>--use-set-session-authorization</option></term>
|
2010-07-22 03:22:35 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
Output SQL-standard <command>SET SESSION AUTHORIZATION</command> commands
|
|
|
|
instead of <command>ALTER OWNER</command> commands to determine object
|
2011-05-25 20:53:26 +02:00
|
|
|
ownership. This makes the dump more standards-compatible, but
|
|
|
|
depending on the history of the objects in the dump, might not restore
|
2017-10-09 03:44:17 +02:00
|
|
|
properly. Also, a dump using <command>SET SESSION AUTHORIZATION</command>
|
2011-05-25 20:53:26 +02:00
|
|
|
will certainly require superuser privileges to restore correctly,
|
2017-10-09 03:44:17 +02:00
|
|
|
whereas <command>ALTER OWNER</command> requires lesser privileges.
|
2010-07-22 03:22:35 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2010-02-19 15:36:45 +01:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-?</option></term>
|
|
|
|
<term><option>--help</option></term>
|
2010-02-19 15:36:45 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Show help about <application>pg_dump</application> command line
|
|
|
|
arguments, and exit.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
</variablelist>
|
|
|
|
</para>
|
2002-08-27 20:57:26 +02:00
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<para>
|
2002-08-27 20:57:26 +02:00
|
|
|
The following command-line options control the database connection parameters.
|
1999-07-06 19:16:42 +02:00
|
|
|
|
|
|
|
<variablelist>
|
2013-02-25 18:39:04 +01:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-d <replaceable class="parameter">dbname</replaceable></option></term>
|
|
|
|
<term><option>--dbname=<replaceable class="parameter">dbname</replaceable></option></term>
|
2013-02-25 18:39:04 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Specifies the name of the database to connect to. This is
|
|
|
|
equivalent to specifying <replaceable
|
|
|
|
class="parameter">dbname</replaceable> as the first non-option
|
2020-10-03 04:19:31 +02:00
|
|
|
argument on the command line. The <replaceable>dbname</replaceable>
|
|
|
|
can be a <link linkend="libpq-connstring">connection string</link>.
|
|
|
|
If so, connection string parameters will override any conflicting
|
|
|
|
command line options.
|
2013-02-25 18:39:04 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-h <replaceable class="parameter">host</replaceable></option></term>
|
|
|
|
<term><option>--host=<replaceable class="parameter">host</replaceable></option></term>
|
1999-07-06 19:16:42 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-03-24 15:32:51 +01:00
|
|
|
Specifies the host name of the machine on which the server is
|
|
|
|
running. If the value begins with a slash, it is used as the
|
|
|
|
directory for the Unix domain socket. The default is taken
|
|
|
|
from the <envar>PGHOST</envar> environment variable, if set,
|
|
|
|
else a Unix domain socket connection is attempted.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-p <replaceable class="parameter">port</replaceable></option></term>
|
|
|
|
<term><option>--port=<replaceable class="parameter">port</replaceable></option></term>
|
1999-07-06 19:16:42 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-01-04 04:58:16 +01:00
|
|
|
Specifies the TCP port or local Unix domain socket file
|
|
|
|
extension on which the server is listening for connections.
|
|
|
|
Defaults to the <envar>PGPORT</envar> environment variable, if
|
|
|
|
set, or a compiled-in default.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-U <replaceable>username</replaceable></option></term>
|
2007-02-01 05:39:33 +01:00
|
|
|
<term><option>--username=<replaceable class="parameter">username</replaceable></option></term>
|
1999-07-06 19:16:42 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-12-11 20:57:32 +01:00
|
|
|
User name to connect as.
|
2001-05-17 23:12:49 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2009-02-26 17:02:39 +01:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-w</option></term>
|
|
|
|
<term><option>--no-password</option></term>
|
2009-02-26 17:02:39 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Never issue a password prompt. If the server requires
|
|
|
|
password authentication and a password is not available by
|
|
|
|
other means such as a <filename>.pgpass</filename> file, the
|
|
|
|
connection attempt will fail. This option can be useful in
|
|
|
|
batch jobs and scripts where no user is present to enter a
|
|
|
|
password.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2001-05-17 23:12:49 +02:00
|
|
|
<varlistentry>
|
2002-03-22 20:20:45 +01:00
|
|
|
<term><option>-W</option></term>
|
2007-02-01 05:39:33 +01:00
|
|
|
<term><option>--password</option></term>
|
2001-05-17 23:12:49 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-12-11 20:57:32 +01:00
|
|
|
Force <application>pg_dump</application> to prompt for a
|
2008-07-20 20:43:30 +02:00
|
|
|
password before connecting to a database.
|
2007-12-11 20:57:32 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This option is never essential, since
|
|
|
|
<application>pg_dump</application> will automatically prompt
|
|
|
|
for a password if the server demands password authentication.
|
|
|
|
However, <application>pg_dump</application> will waste a
|
|
|
|
connection attempt finding out that the server wants a password.
|
2017-10-09 03:44:17 +02:00
|
|
|
In some cases it is worth typing <option>-W</option> to avoid the extra
|
2007-12-11 20:57:32 +01:00
|
|
|
connection attempt.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2009-01-05 17:54:37 +01:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><option>--role=<replaceable class="parameter">rolename</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Specifies a role name to be used to create the dump.
|
2017-10-09 03:44:17 +02:00
|
|
|
This option causes <application>pg_dump</application> to issue a
|
|
|
|
<command>SET ROLE</command> <replaceable class="parameter">rolename</replaceable>
|
2009-01-05 17:54:37 +01:00
|
|
|
command after connecting to the database. It is useful when the
|
2017-10-09 03:44:17 +02:00
|
|
|
authenticated user (specified by <option>-U</option>) lacks privileges
|
|
|
|
needed by <application>pg_dump</application>, but can switch to a role with
|
2009-01-05 17:54:37 +01:00
|
|
|
the required rights. Some installations have a policy against
|
|
|
|
logging in directly as a superuser, and use of this option allows
|
|
|
|
dumps to be made without violating the policy.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
1999-07-06 19:16:42 +02:00
|
|
|
</variablelist>
|
|
|
|
</para>
|
2001-03-06 19:55:57 +01:00
|
|
|
</refsect1>
|
1999-07-06 19:16:42 +02:00
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
<refsect1>
|
|
|
|
<title>Environment</title>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><envar>PGDATABASE</envar></term>
|
|
|
|
<term><envar>PGHOST</envar></term>
|
2009-02-07 15:31:30 +01:00
|
|
|
<term><envar>PGOPTIONS</envar></term>
|
2002-07-28 17:22:21 +02:00
|
|
|
<term><envar>PGPORT</envar></term>
|
|
|
|
|
2009-02-07 15:31:30 +01:00
|
|
|
<term><envar>PGUSER</envar></term>
|
2002-07-28 17:22:21 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-02-13 05:54:16 +01:00
|
|
|
Default connection parameters.
|
2002-07-28 17:22:21 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
2009-02-07 15:31:30 +01:00
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
</varlistentry>
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><envar>PG_COLOR</envar></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2020-03-09 02:53:22 +01:00
|
|
|
Specifies whether to use color in diagnostic messages. Possible values
|
|
|
|
are <literal>always</literal>, <literal>auto</literal> and
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
<literal>never</literal>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2002-07-28 17:22:21 +02:00
|
|
|
</variablelist>
|
2007-02-20 19:10:59 +01:00
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
This utility, like most other <productname>PostgreSQL</productname> utilities,
|
|
|
|
also uses the environment variables supported by <application>libpq</application>
|
2017-11-23 15:39:47 +01:00
|
|
|
(see <xref linkend="libpq-envars"/>).
|
2007-02-20 19:10:59 +01:00
|
|
|
</para>
|
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
</refsect1>
|
|
|
|
|
2001-03-06 19:55:57 +01:00
|
|
|
<refsect1 id="app-pgdump-diagnostics">
|
|
|
|
<title>Diagnostics</title>
|
|
|
|
|
2003-03-24 15:32:51 +01:00
|
|
|
<para>
|
|
|
|
<application>pg_dump</application> internally executes
|
|
|
|
<command>SELECT</command> statements. If you have problems running
|
|
|
|
<application>pg_dump</application>, make sure you are able to
|
|
|
|
select information from the database using, for example, <xref
|
2017-11-23 15:39:47 +01:00
|
|
|
linkend="app-psql"/>. Also, any default connection settings and environment
|
2007-02-20 19:10:59 +01:00
|
|
|
variables used by the <application>libpq</application> front-end
|
|
|
|
library will apply.
|
2003-03-24 15:32:51 +01:00
|
|
|
</para>
|
2009-02-10 01:55:21 +01:00
|
|
|
|
2009-02-07 15:31:30 +01:00
|
|
|
<para>
|
2009-02-07 16:25:51 +01:00
|
|
|
The database activity of <application>pg_dump</application> is
|
2022-04-08 06:35:35 +02:00
|
|
|
normally collected by the cumulative statistics system. If this is
|
2017-10-09 03:44:17 +02:00
|
|
|
undesirable, you can set parameter <varname>track_counts</varname>
|
2009-02-10 01:55:21 +01:00
|
|
|
to false via <envar>PGOPTIONS</envar> or the <literal>ALTER
|
|
|
|
USER</literal> command.
|
2009-02-07 15:31:30 +01:00
|
|
|
</para>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
</refsect1>
|
|
|
|
|
2001-03-06 19:55:57 +01:00
|
|
|
|
|
|
|
<refsect1 id="pg-dump-notes">
|
|
|
|
<title>Notes</title>
|
2002-02-11 01:14:10 +01:00
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
If your database cluster has any local additions to the <literal>template1</literal> database,
|
2002-10-12 01:03:48 +02:00
|
|
|
be careful to restore the output of <application>pg_dump</application> into a
|
2002-02-11 01:14:10 +01:00
|
|
|
truly empty database; otherwise you are likely to get errors due to
|
|
|
|
duplicate definitions of the added objects. To make an empty database
|
2017-10-09 03:44:17 +02:00
|
|
|
without any local additions, copy from <literal>template0</literal> not <literal>template1</literal>,
|
2002-02-11 01:14:10 +01:00
|
|
|
for example:
|
|
|
|
<programlisting>
|
2002-10-12 01:03:48 +02:00
|
|
|
CREATE DATABASE foo WITH TEMPLATE template0;
|
2002-02-11 01:14:10 +01:00
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
When a data-only dump is chosen and the option <option>--disable-triggers</option>
|
2008-08-22 00:25:44 +02:00
|
|
|
is used, <application>pg_dump</application> emits commands
|
2009-03-22 17:44:26 +01:00
|
|
|
to disable triggers on user tables before inserting the data,
|
|
|
|
and then commands to re-enable them after the data has been
|
2008-08-22 00:25:44 +02:00
|
|
|
inserted. If the restore is stopped in the middle, the system
|
|
|
|
catalogs might be left in the wrong state.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
2002-09-06 23:58:36 +02:00
|
|
|
|
2003-03-18 01:02:11 +01:00
|
|
|
<para>
|
2008-08-22 00:25:44 +02:00
|
|
|
The dump file produced by <application>pg_dump</application>
|
|
|
|
does not contain the statistics used by the optimizer to make
|
|
|
|
query planning decisions. Therefore, it is wise to run
|
|
|
|
<command>ANALYZE</command> after restoring from a dump file
|
2017-11-23 15:39:47 +01:00
|
|
|
to ensure optimal performance; see <xref linkend="vacuum-for-statistics"/>
|
|
|
|
and <xref linkend="autovacuum"/> for more information.
|
2003-03-18 01:02:11 +01:00
|
|
|
</para>
|
|
|
|
|
2006-05-13 18:19:54 +02:00
|
|
|
<para>
|
2006-10-23 20:10:32 +02:00
|
|
|
Because <application>pg_dump</application> is used to transfer data
|
2017-10-09 03:44:17 +02:00
|
|
|
to newer versions of <productname>PostgreSQL</productname>, the output of
|
2009-03-22 17:44:26 +01:00
|
|
|
<application>pg_dump</application> can be expected to load into
|
2017-10-09 03:44:17 +02:00
|
|
|
<productname>PostgreSQL</productname> server versions newer than
|
|
|
|
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
|
|
|
|
dump from <productname>PostgreSQL</productname> servers older than its own version.
|
2021-12-14 23:09:07 +01:00
|
|
|
(Currently, servers back to version 9.2 are supported.)
|
2017-10-09 03:44:17 +02:00
|
|
|
However, <application>pg_dump</application> cannot dump from
|
|
|
|
<productname>PostgreSQL</productname> servers newer than its own major version;
|
2009-03-22 17:44:26 +01:00
|
|
|
it will refuse to even try, rather than risk making an invalid dump.
|
2017-10-09 03:44:17 +02:00
|
|
|
Also, it is not guaranteed that <application>pg_dump</application>'s output can
|
2009-03-22 17:44:26 +01:00
|
|
|
be loaded into a server of an older major version — not even if the
|
|
|
|
dump was taken from a server of that version. Loading a dump file
|
|
|
|
into an older server may require manual editing of the dump file
|
|
|
|
to remove syntax not understood by the older server.
|
2016-05-20 21:51:57 +02:00
|
|
|
Use of the <option>--quote-all-identifiers</option> option is recommended
|
|
|
|
in cross-version cases, as it can prevent problems arising from varying
|
2017-10-09 03:44:17 +02:00
|
|
|
reserved-word lists in different <productname>PostgreSQL</productname> versions.
|
2006-05-13 18:19:54 +02:00
|
|
|
</para>
|
2017-04-13 04:12:30 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
When dumping logical replication subscriptions,
|
|
|
|
<application>pg_dump</application> will generate <command>CREATE
|
2019-01-15 00:47:01 +01:00
|
|
|
SUBSCRIPTION</command> commands that use the <literal>connect = false</literal>
|
2017-04-13 04:12:30 +02:00
|
|
|
option, so that restoring the subscription does not make remote connections
|
|
|
|
for creating a replication slot or for initial table copy. That way, the
|
|
|
|
dump can be restored without requiring network access to the remote
|
|
|
|
servers. It is then up to the user to reactivate the subscriptions in a
|
|
|
|
suitable way. If the involved hosts have changed, the connection
|
Add a failover option to subscriptions.
This commit introduces a new subscription option named 'failover', which
provides users with the ability to set the failover property of the
replication slot on the publisher when creating or altering a
subscription.
This uses the replication commands introduced by commit 7329240437 to
enable the failover option for a logical replication slot.
If the failover option is set to true, the associated replication slots
(i.e. the main slot and the table sync slots) in the upstream database are
enabled to be synchronized to the standbys. Note that the capability to
sync the replication slots will be added in subsequent commits.
Thanks to Masahiko Sawada for the design inputs.
Author: Shveta Malik, Hou Zhijie, Ajin Cherian
Reviewed-by: Peter Smith, Bertrand Drouvot, Dilip Kumar, Masahiko Sawada, Nisha Moond, Kuroda Hayato, Amit Kapila
Discussion: https://postgr.es/m/514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com
2024-01-30 12:01:09 +01:00
|
|
|
information might have to be changed. If the subscription needs to
|
|
|
|
be enabled for
|
|
|
|
<link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>,
|
|
|
|
then same needs to be done by executing
|
|
|
|
<link linkend="sql-altersubscription-params-set">
|
|
|
|
<literal>ALTER SUBSCRIPTION ... SET (failover = true)</literal></link>
|
|
|
|
after the slot has been created. It might also be appropriate to
|
Add support for prepared transactions to built-in logical replication.
To add support for streaming transactions at prepare time into the
built-in logical replication, we need to do the following things:
* Modify the output plugin (pgoutput) to implement the new two-phase API
callbacks, by leveraging the extended replication protocol.
* Modify the replication apply worker, to properly handle two-phase
transactions by replaying them on prepare.
* Add a new SUBSCRIPTION option "two_phase" to allow users to enable
two-phase transactions. We enable the two_phase once the initial data sync
is over.
We however must explicitly disable replication of two-phase transactions
during replication slot creation, even if the plugin supports it. We
don't need to replicate the changes accumulated during this phase,
and moreover, we don't have a replication connection open so we don't know
where to send the data anyway.
The streaming option is not allowed with this new two_phase option. This
can be done as a separate patch.
We don't allow to toggle two_phase option of a subscription because it can
lead to an inconsistent replica. For the same reason, we don't allow to
refresh the publication once the two_phase is enabled for a subscription
unless copy_data option is false.
Author: Peter Smith, Ajin Cherian and Amit Kapila based on previous work by Nikhil Sontakke and Stas Kelvich
Reviewed-by: Amit Kapila, Sawada Masahiko, Vignesh C, Dilip Kumar, Takamichi Osumi, Greg Nancarrow
Tested-By: Haiying Tang
Discussion: https://postgr.es/m/02DA5F5E-CECE-4D9C-8B4B-418077E2C010@postgrespro.ru
Discussion: https://postgr.es/m/CAA4eK1+opiV4aFTmWWUF9h_32=HfPOW9vZASHarT0UA5oBrtGw@mail.gmail.com
2021-07-14 04:03:50 +02:00
|
|
|
truncate the target tables before initiating a new full table copy. If users
|
|
|
|
intend to copy initial data during refresh they must create the slot with
|
|
|
|
<literal>two_phase = false</literal>. After the initial sync, the
|
2023-10-30 06:16:31 +01:00
|
|
|
<link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
|
2023-03-29 06:28:14 +02:00
|
|
|
option will be automatically enabled by the subscriber if the subscription
|
|
|
|
had been originally created with <literal>two_phase = true</literal> option.
|
2017-04-13 04:12:30 +02:00
|
|
|
</para>
|
1999-07-06 19:16:42 +02:00
|
|
|
</refsect1>
|
|
|
|
|
Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs.
Use xreflabel attributes instead of endterm attributes to control the
appearance of links to subsections of SQL command reference pages.
This is simpler, it matches what we do elsewhere (e.g. for GUC variables),
and it doesn't draw "Unresolved ID reference" warnings from the PDF
toolchain.
Fix some places where the text was absolutely dependent on an <xref>
rendering exactly so, by using a <link> around the required text
instead. At least one of those spots had already been turned into
bad grammar by subsequent changes, and the whole idea is just too
fragile for my taste. <xref> does NOT have fixed output, don't write
as if it does.
Consistently include a page-level link in cross-man-page references,
because otherwise they are useless/nonsensical in man-page output.
Likewise, be consistent about mentioning "below" or "above" in same-page
references; we were doing that in about 90% of the cases, but now it's
100%.
Also get rid of another nonfunctional-in-PDF idea, of making
cross-references to functions by sticking ID tags on <row> constructs.
We can put the IDs on <indexterm>s instead --- which is probably not any
more sensible in abstract terms, but it works where the other doesn't.
(There is talk of attaching cross-reference IDs to most or all of
the docs' function descriptions, but for now I just fixed the two
that exist.)
Discussion: https://postgr.es/m/14480.1589154358@sss.pgh.pa.us
2020-05-11 20:15:49 +02:00
|
|
|
<refsect1 id="pg-dump-examples" xreflabel="Examples">
|
|
|
|
<title>Examples</title>
|
1999-07-06 19:16:42 +02:00
|
|
|
|
2001-03-06 19:55:57 +01:00
|
|
|
<para>
|
2021-06-11 03:38:04 +02:00
|
|
|
To dump a database called <literal>mydb</literal> into an SQL-script file:
|
2006-10-10 01:36:59 +02:00
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_dump mydb > db.sql</userinput>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
To reload such a script into a (freshly created) database named
|
2017-10-09 03:44:17 +02:00
|
|
|
<literal>newdb</literal>:
|
2006-10-10 01:36:59 +02:00
|
|
|
|
2001-03-06 19:55:57 +01:00
|
|
|
<screen>
|
2006-10-10 01:36:59 +02:00
|
|
|
<prompt>$</prompt> <userinput>psql -d newdb -f db.sql</userinput>
|
2001-03-06 19:55:57 +01:00
|
|
|
</screen>
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2006-10-10 01:36:59 +02:00
|
|
|
To dump a database into a custom-format archive file:
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_dump -Fc mydb > db.dump</userinput>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
2011-01-23 22:10:15 +01:00
|
|
|
<para>
|
|
|
|
To dump a database into a directory-format archive:
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_dump -Fd mydb -f dumpdir</userinput>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
2013-03-24 16:27:20 +01:00
|
|
|
<para>
|
|
|
|
To dump a database into a directory-format archive in parallel with
|
|
|
|
5 worker jobs:
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_dump -Fd mydb -j 5 -f dumpdir</userinput>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
2006-10-10 01:36:59 +02:00
|
|
|
<para>
|
|
|
|
To reload an archive file into a (freshly created) database named
|
2017-10-09 03:44:17 +02:00
|
|
|
<literal>newdb</literal>:
|
2006-10-10 01:36:59 +02:00
|
|
|
|
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_restore -d newdb db.dump</userinput>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
Move handling of database properties from pg_dumpall into pg_dump.
This patch rearranges the division of labor between pg_dump and pg_dumpall
so that pg_dump itself handles all properties attached to a single
database. Notably, a database's ACL (GRANT/REVOKE status) and local GUC
settings established by ALTER DATABASE SET and ALTER ROLE IN DATABASE SET
can be dumped and restored by pg_dump. This is a long-requested
improvement.
"pg_dumpall -g" will now produce only role- and tablespace-related output,
nothing about individual databases. The total output of a regular
pg_dumpall run remains the same.
pg_dump (or pg_restore) will restore database-level properties only when
creating the target database with --create. This applies not only to
ACLs and GUCs but to the other database properties it already handled,
that is database comments and security labels. This is more consistent
and useful, but does represent an incompatibility in the behavior seen
without --create.
(This change makes the proposed patch to have pg_dump use "COMMENT ON
DATABASE CURRENT_DATABASE" unnecessary, since there is no case where
the command is issued that we won't know the true name of the database.
We might still want that patch as a feature in its own right, but pg_dump
no longer needs it.)
pg_dumpall with --clean will now drop and recreate the "postgres" and
"template1" databases in the target cluster, allowing their locale and
encoding settings to be changed if necessary, and providing a cleaner
way to set nondefault tablespaces for them than we had before. This
means that such a script must now always be started in the "postgres"
database; the order of drops and reconnects will not work otherwise.
Without --clean, the script will not adjust any database-level properties
of those two databases (including their comments, ACLs, and security
labels, which it formerly would try to set).
Another minor incompatibility is that the CREATE DATABASE commands in a
pg_dumpall script will now always specify locale and encoding settings.
Formerly those would be omitted if they matched the cluster's default.
While that behavior had some usefulness in some migration scenarios,
it also posed a significant hazard of unwanted locale/encoding changes.
To migrate to another locale/encoding, it's now necessary to use pg_dump
without --create to restore into a database with the desired settings.
Commit 4bd371f6f's hack to emit "SET default_transaction_read_only = off"
is gone: we now dodge that problem by the expedient of not issuing ALTER
DATABASE SET commands until after reconnecting to the target database.
Therefore, such settings won't apply during the restore session.
In passing, improve some shaky grammar in the docs, and add a note pointing
out that pg_dumpall's output can't be expected to load without any errors.
(Someday we might want to fix that, but this is not that patch.)
Haribabu Kommi, reviewed at various times by Andreas Karlsson,
Vaishnavi Prabakaran, and Robert Haas; further hacking by me.
Discussion: https://postgr.es/m/CAJrrPGcUurV0eWTeXODwsOYFN=Ekq36t1s0YnFYUNzsmRfdAyA@mail.gmail.com
2018-01-22 20:09:09 +01:00
|
|
|
<para>
|
|
|
|
To reload an archive file into the same database it was dumped from,
|
|
|
|
discarding the current contents of that database:
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_restore -d postgres --clean --create db.dump</userinput>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
2006-10-10 01:36:59 +02:00
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
To dump a single table named <literal>mytab</literal>:
|
2006-10-10 01:36:59 +02:00
|
|
|
|
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_dump -t mytab mydb > db.sql</userinput>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
To dump all tables whose names start with <literal>emp</literal> in the
|
|
|
|
<literal>detroit</literal> schema, except for the table named
|
2006-10-10 01:36:59 +02:00
|
|
|
<literal>employee_log</literal>:
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb > db.sql</userinput>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
To dump all schemas whose names start with <literal>east</literal> or
|
|
|
|
<literal>west</literal> and end in <literal>gsm</literal>, excluding any schemas whose
|
|
|
|
names contain the word <literal>test</literal>:
|
2006-10-10 01:36:59 +02:00
|
|
|
|
2001-03-06 19:55:57 +01:00
|
|
|
<screen>
|
2006-10-10 01:36:59 +02:00
|
|
|
<prompt>$</prompt> <userinput>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb > db.sql</userinput>
|
2001-03-06 19:55:57 +01:00
|
|
|
</screen>
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
2001-03-05 19:42:57 +01:00
|
|
|
|
|
|
|
<para>
|
2006-10-10 01:36:59 +02:00
|
|
|
The same, using regular expression notation to consolidate the switches:
|
2001-03-05 19:42:57 +01:00
|
|
|
|
2001-03-06 19:55:57 +01:00
|
|
|
<screen>
|
2006-10-10 01:36:59 +02:00
|
|
|
<prompt>$</prompt> <userinput>pg_dump -n '(east|west)*gsm' -N '*test*' mydb > db.sql</userinput>
|
2001-03-06 19:55:57 +01:00
|
|
|
</screen>
|
2001-03-05 19:42:57 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2006-10-10 01:36:59 +02:00
|
|
|
To dump all database objects except for tables whose names begin with
|
|
|
|
<literal>ts_</literal>:
|
2001-03-05 19:42:57 +01:00
|
|
|
|
2001-03-06 19:55:57 +01:00
|
|
|
<screen>
|
2006-10-10 01:36:59 +02:00
|
|
|
<prompt>$</prompt> <userinput>pg_dump -T 'ts_*' mydb > db.sql</userinput>
|
2006-11-28 23:54:18 +01:00
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
To specify an upper-case or mixed-case name in <option>-t</option> and related
|
2006-11-28 23:54:18 +01:00
|
|
|
switches, you need to double-quote the name; else it will be folded to
|
2022-09-23 04:05:09 +02:00
|
|
|
lower case (see <xref linkend="app-psql-patterns"/>). But
|
2006-11-28 23:54:18 +01:00
|
|
|
double quotes are special to the shell, so in turn they must be quoted.
|
|
|
|
Thus, to dump a single table with a mixed-case name, you need something
|
|
|
|
like
|
|
|
|
|
|
|
|
<screen>
|
2013-07-01 20:52:56 +02:00
|
|
|
<prompt>$</prompt> <userinput>pg_dump -t "\"MixedCaseName\"" mydb > mytab.sql</userinput>
|
Read include/exclude commands for dump/restore from file
When there is a need to filter multiple tables with include and/or exclude
options it's quite possible to run into the limitations of the commandline.
This adds a --filter=FILENAME feature to pg_dump, pg_dumpall and pg_restore
which is used to supply a file containing object exclude/include commands
which work just like their commandline counterparts. The format of the file
is one command per row like:
<command> <object> <objectpattern>
<command> can be "include" or "exclude", <object> can be table_data, index
table_data_and_children, database, extension, foreign_data, function, table
schema, table_and_children or trigger.
This patch has gone through many revisions and design changes over a long
period of time, the list of reviewers reflect reviewers of some version of
the patch, not necessarily the final version.
Patch by Pavel Stehule with some additional hacking by me.
Author: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Reviewed-by: Erik Rijkers <er@xs4all.nl>
Discussion: https://postgr.es/m/CAFj8pRB10wvW0CC9Xq=1XDs=zCQxer3cbLcNZa+qiX4cUH-G_A@mail.gmail.com
2023-11-29 14:56:24 +01:00
|
|
|
</screen></para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
To dump all tables whose names start with <literal>mytable</literal>, except
|
|
|
|
for table <literal>mytable2</literal>, specify a filter file
|
|
|
|
<filename>filter.txt</filename> like:
|
|
|
|
<programlisting>
|
|
|
|
include table mytable*
|
|
|
|
exclude table mytable2
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_dump --filter=filter.txt mydb > db.sql</userinput>
|
2011-08-07 09:49:45 +02:00
|
|
|
</screen></para>
|
2001-03-05 19:42:57 +01:00
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
</refsect1>
|
2001-03-06 19:55:57 +01:00
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
|
|
|
|
<simplelist type="inline">
|
2017-11-23 15:39:47 +01:00
|
|
|
<member><xref linkend="app-pg-dumpall"/></member>
|
|
|
|
<member><xref linkend="app-pgrestore"/></member>
|
|
|
|
<member><xref linkend="app-psql"/></member>
|
2001-03-06 19:55:57 +01:00
|
|
|
</simplelist>
|
|
|
|
</refsect1>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
</refentry>
|