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 $ -->
2
2
3
3
<chapter id="backup">
4
4
<title>Backup and Restore</title>
@@ -577,11 +577,10 @@ cp -i pg_xlog/00000001000000A900000065 /mnt/server/archivedir/00000001000000A900
577
577
<para>
578
578
It is important that the archive command return zero exit status if and
579
579
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.
585
584
</para>
586
585
587
586
<para>
@@ -1001,11 +1000,13 @@ restore_command = 'cp /mnt/server/archivedir/%f %p'
1001
1000
1002
1001
<para>
1003
1002
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
1005
1004
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.
1009
1010
</para>
1010
1011
1011
1012
<para>
@@ -1576,19 +1577,21 @@ archive_command = 'local_backup_script.sh'
1576
1577
1577
1578
<para>
1578
1579
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
1582
1583
<filename>recovery.conf</> file on the standby server. Normal recovery
1583
1584
processing would request a file from the WAL archive, reporting failure
1584
1585
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.
1592
1595
</para>
1593
1596
1594
1597
<para>
@@ -1608,9 +1611,10 @@ if (!triggered)
1608
1611
1609
1612
<para>
1610
1613
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.
1614
1618
</para>
1615
1619
1616
1620
<para>
0 commit comments