Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 958db06

Browse files
committed
Clarify documentation on PITR and warm standby on the fact that the standby
restore_command should report failure on non-existent .backup and .history files. Tidy up some related text along the way. Patch by Markus Bertheau, with some editing by Simon Riggs and myself.
1 parent da215f0 commit 958db06

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

doc/src/sgml/backup.sgml

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.115 2008/03/07 01:46:41 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.116 2008/03/28 15:00:28 heikki Exp $ -->
22

33
<chapter id="backup">
44
<title>Backup and Restore</title>
@@ -577,11 +577,10 @@ cp -i pg_xlog/00000001000000A900000065 /mnt/server/archivedir/00000001000000A900
577577
<para>
578578
It is important that the archive command return zero exit status if and
579579
only if it succeeded. Upon getting a zero result,
580-
<productname>PostgreSQL</> will assume that the WAL segment file has been
581-
successfully archived, and will remove or recycle it.
582-
However, a nonzero status tells
583-
<productname>PostgreSQL</> that the file was not archived; it will try
584-
again periodically until it succeeds.
580+
<productname>PostgreSQL</> will assume that the file has been
581+
successfully archived, and will remove or recycle it. However, a nonzero
582+
status tells <productname>PostgreSQL</> that the file was not archived;
583+
it will try again periodically until it succeeds.
585584
</para>
586585

587586
<para>
@@ -1001,11 +1000,13 @@ restore_command = 'cp /mnt/server/archivedir/%f %p'
10011000

10021001
<para>
10031002
It is important that the command return nonzero exit status on failure.
1004-
The command <emphasis>will</> be asked for log files that are not present
1003+
The command <emphasis>will</> be asked for files that are not present
10051004
in the archive; it must return nonzero when so asked. This is not an
1006-
error condition. Be aware also that the base name of the <literal>%p</>
1007-
path will be different from <literal>%f</>; do not expect them to be
1008-
interchangeable.
1005+
error condition. Not all of the requested files will be WAL segment
1006+
files; you should also expect requests for files with a suffix of
1007+
<literal>.backup</> or <literal>.history</>. Also be aware that
1008+
the base name of the <literal>%p</> path will be different from
1009+
<literal>%f</>; do not expect them to be interchangeable.
10091010
</para>
10101011

10111012
<para>
@@ -1576,19 +1577,21 @@ archive_command = 'local_backup_script.sh'
15761577

15771578
<para>
15781579
The magic that makes the two loosely coupled servers work together is
1579-
simply a <varname>restore_command</> used on the standby that waits
1580-
for the next WAL file to become available from the primary. The
1581-
<varname>restore_command</> is specified in the
1580+
simply a <varname>restore_command</> used on the standby that,
1581+
when asked for the next WAL file, waits for it to become available from
1582+
the primary. The <varname>restore_command</> is specified in the
15821583
<filename>recovery.conf</> file on the standby server. Normal recovery
15831584
processing would request a file from the WAL archive, reporting failure
15841585
if the file was unavailable. For standby processing it is normal for
1585-
the next file to be unavailable, so we must be patient and wait for
1586-
it to appear. A waiting <varname>restore_command</> can be written as
1587-
a custom script that loops after polling for the existence of the next
1588-
WAL file. There must also be some way to trigger failover, which should
1589-
interrupt the <varname>restore_command</>, break the loop and return
1590-
a file-not-found error to the standby server. This ends recovery and
1591-
the standby will then come up as a normal server.
1586+
the next WAL file to be unavailable, so we must be patient and wait for
1587+
it to appear. For files ending in <literal>.backup</> or
1588+
<literal>.history</> there is no need to wait, and a non-zero return
1589+
code must be returned. A waiting <varname>restore_command</> can be
1590+
written as a custom script that loops after polling for the existence of
1591+
the next WAL file. There must also be some way to trigger failover, which
1592+
should interrupt the <varname>restore_command</>, break the loop and
1593+
return a file-not-found error to the standby server. This ends recovery
1594+
and the standby will then come up as a normal server.
15921595
</para>
15931596

15941597
<para>
@@ -1608,9 +1611,10 @@ if (!triggered)
16081611

16091612
<para>
16101613
A working example of a waiting <varname>restore_command</> is provided
1611-
as a <filename>contrib</> module named <application>pg_standby</>. This
1612-
example can be extended as needed to support specific configurations or
1613-
environments.
1614+
as a <filename>contrib</> module named <application>pg_standby</>. It
1615+
should be used as a reference on how to correctly implement the logic
1616+
described above. It can also be extended as needed to support specific
1617+
configurations or environments.
16141618
</para>
16151619

16161620
<para>

0 commit comments

Comments
 (0)