Skip to content

Commit 496605b

Browse files
committed
[Issue #66] Documentation
1 parent 040b5a6 commit 496605b

File tree

1 file changed

+137
-2
lines changed

1 file changed

+137
-2
lines changed

doc/pgprobackup.xml

+137-2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ doc/src/sgml/pgprobackup.sgml
196196
backups than by replaying WAL files.
197197
</para>
198198
</listitem>
199+
<listitem>
200+
<para>
201+
Incremental restore: speed up restore from backup by reusing
202+
valid unchanged pages available in PGDATA.
203+
</para>
204+
</listitem>
199205
<listitem>
200206
<para>
201207
Validation: automatic data consistency checks and on-demand
@@ -1698,6 +1704,96 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
16981704
speed up the recovery.
16991705
</para>
17001706
</note>
1707+
<refsect3 id="pbk-incremental-restore">
1708+
<title>Incremental Restore</title>
1709+
<para>
1710+
The speed of restore from backup can be significantly improved
1711+
by replacing only invalid and changed pages in already
1712+
existing PostgreSQL data directory using
1713+
<link linkend="pbk-incremental-restore-options">incremental
1714+
restore options</link> with the <xref linkend="pbk-restore"/>
1715+
command.
1716+
</para>
1717+
<para>
1718+
To restore the database cluster from a backup in incremental mode,
1719+
run the <xref linkend="pbk-restore"/> command with the following options:
1720+
</para>
1721+
<programlisting>
1722+
pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> -D <replaceable>data_dir</replaceable> -I <replaceable>incremental_mode</replaceable>
1723+
</programlisting>
1724+
<para>
1725+
Where <replaceable>incremental_mode</replaceable> can take one of the
1726+
following values:
1727+
</para>
1728+
<itemizedlist spacing="compact">
1729+
<listitem>
1730+
<para>
1731+
CHECKSUM — read all data files in the data directory, validate
1732+
header and checksum in every page and replace only invalid
1733+
pages and those with checksum and LSN not matching with
1734+
corresponding page in backup. This is the simplest,
1735+
the most fool-proof incremental mode.
1736+
</para>
1737+
</listitem>
1738+
<listitem>
1739+
<para>
1740+
LSN — read the <replaceable>pg_control</replaceable> in the
1741+
data directory to obtain redo LSN and redo TLI, which allows
1742+
to determine a point in history(shiftpoint), where data directory
1743+
state shifted from backup chain history. If shiftpoint is not within
1744+
reach of backup chain history, then restore is aborted.
1745+
If shiftpoint is within reach of backup chain history, then read
1746+
all data files in the data directory, validate header and checksum in
1747+
every page and replace only invalid pages and those with LSN greater
1748+
than shiftpoint.
1749+
This mode offer a greatest speed up, but rely on <replaceable>pg_control</replaceable>
1750+
been synched with state of data directory,
1751+
so it is not recommended to use in any situation, where this condition
1752+
is not met, for example, after <replaceable>pg_resetxlog</replaceable> execution,
1753+
after restore from backup without recovery been run, etc.
1754+
</para>
1755+
</listitem>
1756+
<listitem>
1757+
<para>
1758+
NONE — regular restore without any incremental optimizations.
1759+
</para>
1760+
</listitem>
1761+
</itemizedlist>
1762+
1763+
<para>
1764+
Suppose you want to return an old master as replica after switchover
1765+
using incremental restore in LSN mode:
1766+
</para>
1767+
<programlisting>
1768+
=============================================================================================================================================
1769+
Instance Version ID Recovery Time Mode WAL Mode TLI Time Data WAL Zratio Start LSN Stop LSN Status
1770+
=============================================================================================================================================
1771+
node 12 QBRNBP 2020-06-11 17:40:58+03 DELTA ARCHIVE 16/15 40s 194MB 16MB 8.26 15/2C000028 15/2D000128 OK
1772+
node 12 QBRIDX 2020-06-11 15:51:42+03 PAGE ARCHIVE 15/15 11s 18MB 16MB 5.10 14/DC000028 14/DD0000B8 OK
1773+
node 12 QBRIAJ 2020-06-11 15:51:08+03 PAGE ARCHIVE 15/15 20s 141MB 96MB 6.22 14/D4BABFE0 14/DA9871D0 OK
1774+
node 12 QBRHT8 2020-06-11 15:45:56+03 FULL ARCHIVE 15/0 2m:11s 1371MB 416MB 10.93 14/9D000028 14/B782E9A0 OK
1775+
1776+
pg_probackup restore -B /backup --instance node -R -I lsn
1777+
INFO: Running incremental restore into nonempty directory: "/var/lib/pgsql/12/data"
1778+
INFO: Destination directory redo point 15/2E000028 on tli 16 is within reach of backup QBRIDX with Stop LSN 14/DD0000B8 on tli 15, incremental restore in 'lsn' mode is possible
1779+
INFO: shift LSN: 14/DD0000B8
1780+
INFO: Restoring the database from backup at 2020-06-11 15:39:08+03
1781+
INFO: Extracting the content of destination directory for incremental restore
1782+
INFO: Destination directory content extracted, time elapsed: 1s
1783+
INFO: Removing redundant files in destination directory
1784+
INFO: Redundant files are removed, time elapsed: 1s
1785+
INFO: Start restoring backup files. PGDATA size: 15GB
1786+
INFO: Backup files are restored. Transfered bytes: 1693MB, time elapsed: 43s
1787+
INFO: Restore incremental ratio (less is better): 11% (1693MB/15GB)
1788+
INFO: Restore of backup QBRHT8 completed.
1789+
</programlisting>
1790+
<note>
1791+
<para>
1792+
Incremental restore is possible only for backups with
1793+
<literal>program_version</literal> equal or greater than 2.3.0.
1794+
</para>
1795+
</note>
1796+
</refsect3>
17011797
<refsect3 id="pbk-partial-restore">
17021798
<title>Partial Restore</title>
17031799
<para>
@@ -1715,7 +1811,7 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
17151811
</para>
17161812
<programlisting>
17171813
pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> --db-include=<replaceable>database_name</replaceable>
1718-
</programlisting>
1814+
</programlisting>
17191815
<para>
17201816
The <option>--db-include</option> option can be specified
17211817
multiple times. For example, to restore only databases
@@ -3863,7 +3959,7 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
38633959
options</link>,
38643960
<link linkend="pbk-remote-wal-archive-options">remote WAL archive
38653961
options</link>, <link linkend="pbk-logging-opts">logging
3866-
options</link>, <link linkend="pbk-partial-restore">partial
3962+
options</link>, <link linkend="pbk-partial-restore-options">partial
38673963
restore options</link>, and <link linkend="pbk-common-options">common
38683964
options</link> can be used.
38693965
</para>
@@ -5075,6 +5171,45 @@ pg_probackup archive-get -B <replaceable>backup_dir</replaceable> --instance <re
50755171
</variablelist>
50765172
</para>
50775173
</refsect3>
5174+
<refsect3 id="pbk-incremental-restore-options">
5175+
<title>Incremental Restore Options</title>
5176+
<para>
5177+
This section describes the options for incremental cluster restore.
5178+
These options can be used with the
5179+
<xref linkend="pbk-restore"/> command.
5180+
</para>
5181+
<para>
5182+
<variablelist>
5183+
<varlistentry>
5184+
<term><option>-I <replaceable>incremental_mode</replaceable></option></term>
5185+
<term><option>--incremental-mode=<replaceable>incremental_mode</replaceable></option></term>
5186+
<listitem>
5187+
<para>
5188+
Specifies the incremental mode to be used. Possible values are:
5189+
5190+
<itemizedlist spacing="compact">
5191+
<listitem>
5192+
<para>
5193+
<literal>CHECKSUM</literal> — replace only pages with mismatched checksum and LSN.
5194+
</para>
5195+
</listitem>
5196+
<listitem>
5197+
<para>
5198+
<literal>LSN</literal> — replace only pages with LSN greater than point of divergence.
5199+
</para>
5200+
</listitem>
5201+
<listitem>
5202+
<para>
5203+
<literal>NONE</literal> — regular restore.
5204+
</para>
5205+
</listitem>
5206+
</itemizedlist>
5207+
</para>
5208+
</listitem>
5209+
</varlistentry>
5210+
</variablelist>
5211+
</para>
5212+
</refsect3>
50785213
<refsect3 id="pbk-partial-restore-options">
50795214
<title>Partial Restore Options</title>
50805215
<para>

0 commit comments

Comments
 (0)