Doc: various improvements for pg_basebackup reference page.

Put the -r option in the right section (it certainly isn't an
option controlling "the location and format of the output").

Clarify the behavior of the tablespace and waldir options
(that part per gripe from robert@interactive.co.uk).

Make a large number of small copy-editing fixes in text that
visibly wasn't written by native speakers, and try to avoid
grammatical inconsistencies between the descriptions of
the different options.

Back-patch to v13, since HEAD hasn't meaningfully diverged yet.

Discussion: https://postgr.es/m/159749418850.14322.216503677134569752@wrigleys.postgresql.org
This commit is contained in:
Tom Lane 2020-08-15 15:43:34 -04:00
parent 592a589a04
commit 277e49eca7
1 changed files with 174 additions and 156 deletions

View File

@ -9,7 +9,7 @@ PostgreSQL documentation
</indexterm> </indexterm>
<refmeta> <refmeta>
<refentrytitle>pg_basebackup</refentrytitle> <refentrytitle><application>pg_basebackup</application></refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
<refmiscinfo>Application</refmiscinfo> <refmiscinfo>Application</refmiscinfo>
</refmeta> </refmeta>
@ -29,51 +29,51 @@ PostgreSQL documentation
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para> <para>
<application>pg_basebackup</application> is used to take base backups of <application>pg_basebackup</application> is used to take a base backup of
a running <productname>PostgreSQL</productname> database cluster. These a running <productname>PostgreSQL</productname> database cluster. The backup
are taken without affecting other clients to the database, and can be used is taken without affecting other clients of the database, and can be used
both for point-in-time recovery (see <xref linkend="continuous-archiving"/>) both for point-in-time recovery (see <xref linkend="continuous-archiving"/>)
and as the starting point for a log shipping or streaming replication standby and as the starting point for a log-shipping or streaming-replication standby
servers (see <xref linkend="warm-standby"/>). server (see <xref linkend="warm-standby"/>).
</para> </para>
<para> <para>
<application>pg_basebackup</application> makes a binary copy of the database <application>pg_basebackup</application> makes an exact copy of the database
cluster files, while making sure the system is put in and cluster's files, while making sure the server is put into and
out of backup mode automatically. Backups are always taken of the entire out of backup mode automatically. Backups are always taken of the entire
database cluster; it is not possible to back up individual databases or database cluster; it is not possible to back up individual databases or
database objects. For individual database backups, a tool such as database objects. For selective backups, another tool such as
<xref linkend="app-pgdump"/> must be used. <xref linkend="app-pgdump"/> must be used.
</para> </para>
<para> <para>
The backup is made over a regular <productname>PostgreSQL</productname> The backup is made over a regular <productname>PostgreSQL</productname>
connection, and uses the replication protocol. The connection must be made connection that uses the replication protocol. The connection must be made
with a user having <literal>REPLICATION</literal> permissions with a user ID that has <literal>REPLICATION</literal> permissions
(see <xref linkend="role-attributes"/>) or a superuser, (see <xref linkend="role-attributes"/>) or is a superuser,
and <filename>pg_hba.conf</filename> must explicitly permit the replication and <link linkend="auth-pg-hba-conf"><filename>pg_hba.conf</filename></link>
connection. The server must also be configured must permit the replication connection. The server must also be configured
with <xref linkend="guc-max-wal-senders"/> set high enough to leave at least with <xref linkend="guc-max-wal-senders"/> set high enough to provide at
one session available for the backup and one for WAL streaming (if used). least one walsender for the backup plus one for WAL streaming (if used).
</para> </para>
<para> <para>
There can be multiple <command>pg_basebackup</command>s running at the same time, but it is There can be multiple <command>pg_basebackup</command>s running at the same time, but it is usually
better from a performance point of view to take only one backup, and copy better from a performance point of view to take only one backup, and copy
the result. the result.
</para> </para>
<para> <para>
<application>pg_basebackup</application> can make a base backup from <application>pg_basebackup</application> can make a base backup from
not only the master but also the standby. To take a backup from the standby, not only a primary server but also a standby. To take a backup from a standby,
set up the standby so that it can accept replication connections (that is, set set up the standby so that it can accept replication connections (that is, set
<varname>max_wal_senders</varname> and <xref linkend="guc-hot-standby"/>, <varname>max_wal_senders</varname> and <xref linkend="guc-hot-standby"/>,
and configure <link linkend="auth-pg-hba-conf">host-based authentication</link>). and configure its <filename>pg_hba.conf</filename> appropriately).
You will also need to enable <xref linkend="guc-full-page-writes"/> on the master. You will also need to enable <xref linkend="guc-full-page-writes"/> on the primary.
</para> </para>
<para> <para>
Note that there are some limitations in an online backup from the standby: Note that there are some limitations in taking a backup from a standby:
<itemizedlist> <itemizedlist>
<listitem> <listitem>
@ -89,13 +89,13 @@ PostgreSQL documentation
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
If the standby is promoted to the master during online backup, the backup fails. If the standby is promoted to be primary during backup, the backup fails.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
All WAL records required for the backup must contain sufficient full-page writes, All WAL records required for the backup must contain sufficient full-page writes,
which requires you to enable <varname>full_page_writes</varname> on the master and which requires you to enable <varname>full_page_writes</varname> on the primary and
not to use a tool like <application>pg_compresslog</application> as not to use a tool like <application>pg_compresslog</application> as
<varname>archive_command</varname> to remove full-page writes from WAL files. <varname>archive_command</varname> to remove full-page writes from WAL files.
</para> </para>
@ -105,7 +105,7 @@ PostgreSQL documentation
<para> <para>
Whenever <application>pg_basebackup</application> is taking a base Whenever <application>pg_basebackup</application> is taking a base
backup, the <structname>pg_stat_progress_basebackup</structname> backup, the server's <structname>pg_stat_progress_basebackup</structname>
view will report the progress of the backup. view will report the progress of the backup.
See <xref linkend="basebackup-progress-reporting"/> for details. See <xref linkend="basebackup-progress-reporting"/> for details.
</para> </para>
@ -116,7 +116,7 @@ PostgreSQL documentation
<para> <para>
The following command-line options control the location and format of the The following command-line options control the location and format of the
output. output:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
@ -124,15 +124,15 @@ PostgreSQL documentation
<term><option>--pgdata=<replaceable class="parameter">directory</replaceable></option></term> <term><option>--pgdata=<replaceable class="parameter">directory</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Directory to write the output to. Sets the target directory to write the output to.
<application>pg_basebackup</application> will create the directory and <application>pg_basebackup</application> will create this directory
any parent directories if necessary. The directory may already exist, (and any missing parent directories) if it does not exist. If it
but it is an error if the directory already exists and is not empty. already exists, it must be empty.
</para> </para>
<para> <para>
When the backup is in tar mode, and the directory is specified as When the backup is in tar format, the target directory may be
<literal>-</literal> (dash), the tar file will be written to specified as <literal>-</literal> (dash), causing the tar file to be
<literal>stdout</literal>. written to <literal>stdout</literal>.
</para> </para>
<para> <para>
This option is required. This option is required.
@ -155,12 +155,12 @@ PostgreSQL documentation
<listitem> <listitem>
<para> <para>
Write the output as plain files, with the same layout as the Write the output as plain files, with the same layout as the
current data directory and tablespaces. When the cluster has source server's data directory and tablespaces. When the cluster has
no additional tablespaces, the whole database will be placed in no additional tablespaces, the whole database will be placed in
the target directory. If the cluster contains additional the target directory. If the cluster contains additional
tablespaces, the main data directory will be placed in the tablespaces, the main data directory will be placed in the
target directory, but all other tablespaces will be placed target directory, but all other tablespaces will be placed
in the same absolute path as they have on the server. in the same absolute path as they have on the source server.
</para> </para>
<para> <para>
This is the default format. This is the default format.
@ -174,15 +174,15 @@ PostgreSQL documentation
<listitem> <listitem>
<para> <para>
Write the output as tar files in the target directory. The main Write the output as tar files in the target directory. The main
data directory will be written to a file named data directory's contents will be written to a file named
<filename>base.tar</filename>, and all other tablespaces will <filename>base.tar</filename>, and each other tablespace will be
be named after the tablespace OID. written to a separate tar file named after that tablespace's OID.
</para> </para>
<para> <para>
If the value <literal>-</literal> (dash) is specified as If the target directory is specified as <literal>-</literal>
target directory, the tar contents will be written to (dash), the tar contents will be written to
standard output, suitable for piping to for example standard output, suitable for piping to (for example)
<productname>gzip</productname>. This is only possible if <productname>gzip</productname>. This is only allowed if
the cluster has no additional tablespaces and WAL the cluster has no additional tablespaces and WAL
streaming is not used. streaming is not used.
</para> </para>
@ -192,40 +192,22 @@ PostgreSQL documentation
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-r <replaceable class="parameter">rate</replaceable></option></term>
<term><option>--max-rate=<replaceable class="parameter">rate</replaceable></option></term>
<listitem>
<para>
The maximum transfer rate of data transferred from the server. Values are
in kilobytes per second. Use a suffix of <literal>M</literal> to indicate megabytes
per second. A suffix of <literal>k</literal> is also accepted, and has no effect.
Valid values are between 32 kilobytes per second and 1024 megabytes per second.
</para>
<para>
The purpose is to limit the impact of <application>pg_basebackup</application>
on the running server.
</para>
<para>
This option always affects transfer of the data directory. Transfer of
WAL files is only affected if the collection method is <literal>fetch</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-R</option></term> <term><option>-R</option></term>
<term><option>--write-recovery-conf</option></term> <term><option>--write-recovery-conf</option></term>
<listitem> <listitem>
<para> <para>
Create <filename>standby.signal</filename> and append connection settings Creates a <filename>standby.signal</filename> file and appends
to <filename>postgresql.auto.conf</filename> in the output connection settings to the <filename>postgresql.auto.conf</filename>
directory (or into the base archive file when using tar format) to file in the target directory (or within the base archive file when
ease setting up a standby server. using tar format). This eases setting up a standby server using the
results of the backup.
</para>
<para>
The <filename>postgresql.auto.conf</filename> file will record the connection The <filename>postgresql.auto.conf</filename> file will record the connection
settings and, if specified, the replication slot settings and, if specified, the replication slot
that <application>pg_basebackup</application> is using, so that the that <application>pg_basebackup</application> is using, so that
streaming replication will use the same settings later on. streaming replication will use the same settings later on.
</para> </para>
@ -237,17 +219,21 @@ PostgreSQL documentation
<term><option>--tablespace-mapping=<replaceable class="parameter">olddir</replaceable>=<replaceable class="parameter">newdir</replaceable></option></term> <term><option>--tablespace-mapping=<replaceable class="parameter">olddir</replaceable>=<replaceable class="parameter">newdir</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Relocate the tablespace in directory <replaceable>olddir</replaceable> Relocates the tablespace in directory <replaceable>olddir</replaceable>
to <replaceable>newdir</replaceable> during the backup. To be to <replaceable>newdir</replaceable> during the backup. To be
effective, <replaceable>olddir</replaceable> must exactly match the effective, <replaceable>olddir</replaceable> must exactly match the
path specification of the tablespace as it is currently defined. (But path specification of the tablespace as it is defined on the source
it is not an error if there is no tablespace server. (But it is not an error if there is no tablespace
in <replaceable>olddir</replaceable> contained in the backup.) in <replaceable>olddir</replaceable> on the source server.)
Meanwhile <replaceable>newdir</replaceable> is a directory in the
receiving host's filesystem. As with the main target directory,
<replaceable>newdir</replaceable> need not exist already, but if
it does exist it must be empty.
Both <replaceable>olddir</replaceable> Both <replaceable>olddir</replaceable>
and <replaceable>newdir</replaceable> must be absolute paths. If a and <replaceable>newdir</replaceable> must be absolute paths. If
path happens to contain a <literal>=</literal> sign, escape it with a either path needs to contain an equal sign (<literal>=</literal>),
backslash. This option can be specified multiple times for multiple precede that with a backslash. This option can be specified multiple
tablespaces. See examples below. times for multiple tablespaces.
</para> </para>
<para> <para>
@ -263,10 +249,16 @@ PostgreSQL documentation
<term><option>--waldir=<replaceable class="parameter">waldir</replaceable></option></term> <term><option>--waldir=<replaceable class="parameter">waldir</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Specifies the location for the write-ahead log directory. Sets the directory to write WAL (write-ahead log) files to.
By default WAL files will be placed in
the <filename>pg_wal</filename> subdirectory of the target
directory, but this option can be used to place them elsewhere.
<replaceable>waldir</replaceable> must be an absolute path. <replaceable>waldir</replaceable> must be an absolute path.
The write-ahead log directory can only be specified when As with the main target directory,
the backup is in plain mode. <replaceable>waldir</replaceable> need not exist already, but if
it does exist it must be empty.
This option can only be specified when
the backup is in plain format.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -276,16 +268,16 @@ PostgreSQL documentation
<term><option>--wal-method=<replaceable class="parameter">method</replaceable></option></term> <term><option>--wal-method=<replaceable class="parameter">method</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Includes the required write-ahead log files (WAL files) in the Includes the required WAL (write-ahead log) files in the
backup. This will include all write-ahead logs generated during backup. This will include all write-ahead logs generated during
the backup. Unless the method <literal>none</literal> is specified, the backup. Unless the method <literal>none</literal> is specified,
it is possible to start a postmaster directly in the extracted it is possible to start a postmaster in the target
directory without the need to consult the log archive, thus directory without the need to consult the log archive, thus
making this a completely standalone backup. making the output a completely standalone backup.
</para> </para>
<para> <para>
The following methods for collecting the write-ahead logs are The following <replaceable>method</replaceable>s for collecting the
supported: write-ahead logs are supported:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
@ -293,7 +285,7 @@ PostgreSQL documentation
<term><literal>none</literal></term> <term><literal>none</literal></term>
<listitem> <listitem>
<para> <para>
Don't include write-ahead log in the backup. Don't include write-ahead logs in the backup.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -304,15 +296,16 @@ PostgreSQL documentation
<listitem> <listitem>
<para> <para>
The write-ahead log files are collected at the end of the backup. The write-ahead log files are collected at the end of the backup.
Therefore, it is necessary for the Therefore, it is necessary for the source server's
<xref linkend="guc-wal-keep-size"/> parameter to be set high <xref linkend="guc-wal-keep-size"/> parameter to be set high
enough that the log is not removed before the end of the backup. enough that the required log data is not removed before the end
If the log has been rotated when it's time to transfer it, the of the backup. If the required log data has been recycled
backup will fail and be unusable. before it's time to transfer it, the backup will fail and be
unusable.
</para> </para>
<para> <para>
When tar format mode is used, the write-ahead log files will be When tar format is used, the write-ahead log files will be
written to the <filename>base.tar</filename> file. included in the <filename>base.tar</filename> file.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -322,16 +315,16 @@ PostgreSQL documentation
<term><literal>stream</literal></term> <term><literal>stream</literal></term>
<listitem> <listitem>
<para> <para>
Stream the write-ahead log while the backup is created. This will Stream write-ahead log data while the backup is being taken.
open a second connection to the server and start streaming the This method will open a second connection to the server and
write-ahead log in parallel while running the backup. Therefore, start streaming the write-ahead log in parallel while running
it will use up two connections configured by the the backup. Therefore, it will require two replication
<xref linkend="guc-max-wal-senders"/> parameter. As long as the connections not just one. As long as the client can keep up
client can keep up with write-ahead log received, using this mode with the write-ahead log data, using this method requires no
requires no extra write-ahead logs to be saved on the master. extra write-ahead logs to be saved on the source server.
</para> </para>
<para> <para>
When tar format mode is used, the write-ahead log files will be When tar format is used, the write-ahead log files will be
written to a separate file named <filename>pg_wal.tar</filename> written to a separate file named <filename>pg_wal.tar</filename>
(if the server is a version earlier than 10, the file will be named (if the server is a version earlier than 10, the file will be named
<filename>pg_xlog.tar</filename>). <filename>pg_xlog.tar</filename>).
@ -375,7 +368,7 @@ PostgreSQL documentation
</para> </para>
<para> <para>
The following command-line options control the generation of the The following command-line options control the generation of the
backup and the running of the program. backup and the running of the program:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
@ -383,7 +376,8 @@ PostgreSQL documentation
<term><option>--checkpoint=<replaceable class="parameter">fast|spread</replaceable></option></term> <term><option>--checkpoint=<replaceable class="parameter">fast|spread</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Sets checkpoint mode to fast (immediate) or spread (default) (see <xref linkend="backup-lowlevel-base-backup"/>). Sets checkpoint mode to fast (immediate) or spread (the default)
(see <xref linkend="backup-lowlevel-base-backup"/>).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -393,9 +387,9 @@ PostgreSQL documentation
<term><option>--create-slot</option></term> <term><option>--create-slot</option></term>
<listitem> <listitem>
<para> <para>
This option causes creation of a replication slot named by the Specifies that the replication slot named by the
<literal>--slot</literal> option before starting the backup. <literal>--slot</literal> option should be created before starting
An error is raised if the slot already exists. the backup. An error is raised if the slot already exists.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -418,9 +412,9 @@ PostgreSQL documentation
<para> <para>
By default, when <command>pg_basebackup</command> aborts with an By default, when <command>pg_basebackup</command> aborts with an
error, it removes any directories it might have created before error, it removes any directories it might have created before
discovering that it cannot finish the job (for example, data directory discovering that it cannot finish the job (for example, the target
and write-ahead log directory). This option inhibits tidying-up and is directory and write-ahead log directory). This option inhibits
thus useful for debugging. tidying-up and is thus useful for debugging.
</para> </para>
<para> <para>
@ -460,19 +454,41 @@ PostgreSQL documentation
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-r <replaceable class="parameter">rate</replaceable></option></term>
<term><option>--max-rate=<replaceable class="parameter">rate</replaceable></option></term>
<listitem>
<para>
Sets the maximum transfer rate at which data is collected from the
source server. This can be useful to limit the impact
of <application>pg_basebackup</application> on the server. Values
are in kilobytes per second. Use a suffix of <literal>M</literal>
to indicate megabytes per second. A suffix of <literal>k</literal>
is also accepted, and has no effect. Valid values are between 32
kilobytes per second and 1024 megabytes per second.
</para>
<para>
This option always affects transfer of the data directory. Transfer of
WAL files is only affected if the collection method
is <literal>fetch</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-S <replaceable>slotname</replaceable></option></term> <term><option>-S <replaceable>slotname</replaceable></option></term>
<term><option>--slot=<replaceable class="parameter">slotname</replaceable></option></term> <term><option>--slot=<replaceable class="parameter">slotname</replaceable></option></term>
<listitem> <listitem>
<para> <para>
This option can only be used together with <literal>-X This option can only be used together with <literal>-X
stream</literal>. It causes the WAL streaming to use the specified stream</literal>. It causes WAL streaming to use the specified
replication slot. If the base backup is intended to be used as a replication slot. If the base backup is intended to be used as a
streaming replication standby using replication slots, it should then streaming-replication standby using a replication slot, the standby
use the same replication slot name should then use the same replication slot name as
in <xref linkend="guc-primary-slot-name"/>. That way, it is ensured that <xref linkend="guc-primary-slot-name"/>. This ensures that the
the server does not remove any necessary WAL data in the time between primary server does not remove any necessary WAL data in the time
the end of the base backup and the start of streaming replication. between the end of the base backup and the start of streaming
replication on the new standby.
</para> </para>
<para> <para>
The specified replication slot has to exist unless the The specified replication slot has to exist unless the
@ -522,15 +538,15 @@ PostgreSQL documentation
<para> <para>
Using a SHA hash function provides a cryptographically secure digest Using a SHA hash function provides a cryptographically secure digest
of each file for users who wish to verify that the backup has not been of each file for users who wish to verify that the backup has not been
tampered with, while the CRC32C algorithm provides a checksum which is tampered with, while the CRC32C algorithm provides a checksum that is
much faster to calculate and good at catching errors due to accidental much faster to calculate; it is good at catching errors due to accidental
changes but is not resistant to targeted modifications. Note that, to changes but is not resistant to targeted modifications. Note that, to
be useful against an adversary who has access to the backup, the backup be useful against an adversary who has access to the backup, the backup
manifest would need to be stored securely elsewhere or otherwise manifest would need to be stored securely elsewhere or otherwise
verified not to have been modified since the backup was taken. verified not to have been modified since the backup was taken.
</para> </para>
<para> <para>
<xref linkend="app-pgverifybackup" /> can be used to check the <xref linkend="app-pgverifybackup"/> can be used to check the
integrity of a backup against the backup manifest. integrity of a backup against the backup manifest.
</para> </para>
</listitem> </listitem>
@ -552,11 +568,11 @@ PostgreSQL documentation
<term><option>--no-estimate-size</option></term> <term><option>--no-estimate-size</option></term>
<listitem> <listitem>
<para> <para>
This option prevents the server from estimating the total Prevents the server from estimating the total
amount of backup data that will be streamed, resulting in the amount of backup data that will be streamed, resulting in the
<literal>backup_total</literal> column in the <structfield>backup_total</structfield> column in the
<structname>pg_stat_progress_basebackup</structname> <structname>pg_stat_progress_basebackup</structname> view
to be <literal>NULL</literal>. always being <literal>NULL</literal>.
</para> </para>
<para> <para>
Without this option, the backup will start by enumerating Without this option, the backup will start by enumerating
@ -578,7 +594,7 @@ PostgreSQL documentation
<para> <para>
Disables generation of a backup manifest. If this option is not Disables generation of a backup manifest. If this option is not
specified, the server will generate and send a backup manifest specified, the server will generate and send a backup manifest
which can be verified using <xref linkend="app-pgverifybackup" />. which can be verified using <xref linkend="app-pgverifybackup"/>.
The manifest is a list of every file present in the backup with the The manifest is a list of every file present in the backup with the
exception of any WAL files that may be included. It also stores the exception of any WAL files that may be included. It also stores the
size, last modification time, and an optional checksum for each file. size, last modification time, and an optional checksum for each file.
@ -590,16 +606,17 @@ PostgreSQL documentation
<term><option>--no-slot</option></term> <term><option>--no-slot</option></term>
<listitem> <listitem>
<para> <para>
This option prevents the creation of a temporary replication slot Prevents the creation of a temporary replication slot
during the backup even if it's supported by the server. for the backup.
</para> </para>
<para> <para>
Temporary replication slots are created by default if no slot name By default, if log streaming is selected but no slot name is given
is given with the option <option>-S</option> when using log streaming. with the <option>-S</option> option, then a temporary replication
slot is created (if supported by the source server).
</para> </para>
<para> <para>
The main purpose of this option is to allow taking a base backup when The main purpose of this option is to allow taking a base backup when
the server is out of free replication slots. Using replication slots the server has no free replication slots. Using a replication slot
is almost always preferred, because it prevents needed WAL from being is almost always preferred, because it prevents needed WAL from being
removed by the server during the backup. removed by the server during the backup.
</para> </para>
@ -617,7 +634,7 @@ PostgreSQL documentation
By default, checksums are verified and checksum failures will result By default, checksums are verified and checksum failures will result
in a non-zero exit status. However, the base backup will not be in a non-zero exit status. However, the base backup will not be
removed in such a case, as if the <option>--no-clean</option> option removed in such a case, as if the <option>--no-clean</option> option
had been used. Checksum verifications failures will also be reported had been used. Checksum verification failures will also be reported
in the <link linkend="monitoring-pg-stat-database-view"> in the <link linkend="monitoring-pg-stat-database-view">
<structname>pg_stat_database</structname></link> view. <structname>pg_stat_database</structname></link> view.
</para> </para>
@ -627,7 +644,8 @@ PostgreSQL documentation
</para> </para>
<para> <para>
The following command-line options control the database connection parameters. The following command-line options control the connection to the source
server:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
@ -641,7 +659,7 @@ PostgreSQL documentation
<para> <para>
The option is called <literal>--dbname</literal> for consistency with other The option is called <literal>--dbname</literal> for consistency with other
client applications, but because <application>pg_basebackup</application> client applications, but because <application>pg_basebackup</application>
doesn't connect to any particular database in the cluster, database doesn't connect to any particular database in the cluster, any database
name in the connection string will be ignored. name in the connection string will be ignored.
</para> </para>
</listitem> </listitem>
@ -654,7 +672,7 @@ PostgreSQL documentation
<para> <para>
Specifies the host name of the machine on which the server is 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 running. If the value begins with a slash, it is used as the
directory for the Unix domain socket. The default is taken directory for a Unix domain socket. The default is taken
from the <envar>PGHOST</envar> environment variable, if set, from the <envar>PGHOST</envar> environment variable, if set,
else a Unix domain socket connection is attempted. else a Unix domain socket connection is attempted.
</para> </para>
@ -679,11 +697,12 @@ PostgreSQL documentation
<term><option>--status-interval=<replaceable class="parameter">interval</replaceable></option></term> <term><option>--status-interval=<replaceable class="parameter">interval</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Specifies the number of seconds between status packets sent back to the Specifies the number of seconds between status packets sent back to
server. This allows for easier monitoring of the progress from server. the source server. Smaller values allow more accurate monitoring of
A value of zero disables the periodic status updates completely, backup progress from the server.
A value of zero disables periodic status updates completely,
although an update will still be sent when requested by the server, to although an update will still be sent when requested by the server, to
avoid timeout disconnect. The default value is 10 seconds. avoid timeout-based disconnects. The default value is 10 seconds.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -693,7 +712,7 @@ PostgreSQL documentation
<term><option>--username=<replaceable class="parameter">username</replaceable></option></term> <term><option>--username=<replaceable class="parameter">username</replaceable></option></term>
<listitem> <listitem>
<para> <para>
User name to connect as. Specifies the user name to connect as.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -703,7 +722,7 @@ PostgreSQL documentation
<term><option>--no-password</option></term> <term><option>--no-password</option></term>
<listitem> <listitem>
<para> <para>
Never issue a password prompt. If the server requires Prevents issuing a password prompt. If the server requires
password authentication and a password is not available by password authentication and a password is not available by
other means such as a <filename>.pgpass</filename> file, the other means such as a <filename>.pgpass</filename> file, the
connection attempt will fail. This option can be useful in connection attempt will fail. This option can be useful in
@ -718,8 +737,8 @@ PostgreSQL documentation
<term><option>--password</option></term> <term><option>--password</option></term>
<listitem> <listitem>
<para> <para>
Force <application>pg_basebackup</application> to prompt for a Forces <application>pg_basebackup</application> to prompt for a
password before connecting to a database. password before connecting to the source server.
</para> </para>
<para> <para>
@ -745,7 +764,7 @@ PostgreSQL documentation
<term><option>--version</option></term> <term><option>--version</option></term>
<listitem> <listitem>
<para> <para>
Print the <application>pg_basebackup</application> version and exit. Prints the <application>pg_basebackup</application> version and exits.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -755,8 +774,8 @@ PostgreSQL documentation
<term><option>--help</option></term> <term><option>--help</option></term>
<listitem> <listitem>
<para> <para>
Show help about <application>pg_basebackup</application> command line Shows help about <application>pg_basebackup</application> command line
arguments, and exit. arguments, and exits.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -787,11 +806,10 @@ PostgreSQL documentation
<title>Notes</title> <title>Notes</title>
<para> <para>
At the beginning of the backup, a checkpoint needs to be written on the At the beginning of the backup, a checkpoint needs to be performed on the
server the backup is taken from. Especially if the option source server. This can take some time (especially if the option
<literal>--checkpoint=fast</literal> is not used, this can take some time <literal>--checkpoint=fast</literal> is not used), during
during which <application>pg_basebackup</application> will be appear which <application>pg_basebackup</application> will appear to be idle.
to be idle.
</para> </para>
<para> <para>
@ -806,8 +824,8 @@ PostgreSQL documentation
</para> </para>
<para> <para>
Tablespaces will in plain format by default be backed up to the same path In plain format, tablespaces will be backed up to the same path
they have on the server, unless the they have on the source server, unless the
option <literal>--tablespace-mapping</literal> is used. Without option <literal>--tablespace-mapping</literal> is used. Without
this option, running a plain format base backup on the same host as the this option, running a plain format base backup on the same host as the
server will not work if tablespaces are in use, because the backup would server will not work if tablespaces are in use, because the backup would
@ -816,8 +834,9 @@ PostgreSQL documentation
</para> </para>
<para> <para>
When tar format mode is used, it is the user's responsibility to unpack each When tar format is used, it is the user's responsibility to unpack each
tar file before starting the PostgreSQL server. If there are additional tablespaces, the tar file before starting a PostgreSQL server that uses the data. If there
are additional tablespaces, the
tar files for them need to be unpacked in the correct locations. In this tar files for them need to be unpacked in the correct locations. In this
case the symbolic links for those tablespaces will be created by the server case the symbolic links for those tablespaces will be created by the server
according to the contents of the <filename>tablespace_map</filename> file that is according to the contents of the <filename>tablespace_map</filename> file that is
@ -827,15 +846,14 @@ PostgreSQL documentation
<para> <para>
<application>pg_basebackup</application> works with servers of the same <application>pg_basebackup</application> works with servers of the same
or an older major version, down to 9.1. However, WAL streaming mode (<literal>-X or an older major version, down to 9.1. However, WAL streaming mode (<literal>-X
stream</literal>) only works with server version 9.3 and later, and tar format mode stream</literal>) only works with server version 9.3 and later, and tar format
(<literal>--format=tar</literal>) of the current version only works with server version 9.5 (<literal>--format=tar</literal>) only works with server version 9.5
or later. and later.
</para> </para>
<para> <para>
<application>pg_basebackup</application> will preserve group permissions in <application>pg_basebackup</application> will preserve group permissions
both the <literal>plain</literal> and <literal>tar</literal> formats if group for data files if group permissions are enabled on the source cluster.
permissions are enabled on the source cluster.
</para> </para>
</refsect1> </refsect1>