Skip to content

Commit 8405c4e

Browse files
author
Liudmila Mantrova
committed
DOC: review retention-related pbk docs - PBCKP-95
1 parent 1f45bd6 commit 8405c4e

File tree

1 file changed

+92
-67
lines changed

1 file changed

+92
-67
lines changed

doc/pgprobackup.xml

Lines changed: 92 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ pg_probackup checkdb [-B <replaceable>backup_dir</replaceable> [--instance <repl
14751475
enough to specify the backup instance of this cluster for
14761476
<application>pg_probackup</application> to determine the required
14771477
connection options. However, if <literal>-B</literal> and
1478-
<literal>--instance</literal> options are ommitted, you have to provide
1478+
<literal>--instance</literal> options are omitted, you have to provide
14791479
<link linkend="pbk-connection-opts">connection options</link> and
14801480
<replaceable>data_dir</replaceable> via environment
14811481
variables or command-line options.
@@ -2364,7 +2364,8 @@ primary_conninfo = 'user=backup passfile=/var/lib/pgsql/.pgpass port=5432 sslmod
23642364
<listitem>
23652365
<para>
23662366
<literal>expire-time</literal> — the point in time
2367-
when a pinned backup can be removed by retention purge.
2367+
when a pinned backup can be removed in accordance with retention
2368+
policy. This attribute is only available for pinned backups.
23682369
</para>
23692370
</listitem>
23702371
<listitem>
@@ -2808,17 +2809,19 @@ pg_probackup show -B <replaceable>backup_dir</replaceable> [--instance <replacea
28082809
<refsect2 id="pbk-configuring-retention-policy">
28092810
<title>Configuring Retention Policy</title>
28102811
<para>
2811-
With <application>pg_probackup</application>, you can set retention policies for backups
2812-
and WAL archive. All policies can be combined together in any
2813-
way.
2812+
With <application>pg_probackup</application>, you can configure
2813+
retention policy to remove redundant backups, clean up unneeded
2814+
WAL files, as well as pin specific backups to ensure they are
2815+
kept for the specified time, as explained in the sections below.
2816+
All these actions can be combined together in any way.
28142817
</para>
2818+
28152819
<refsect3 id="pbk-retention-policy">
2816-
<title>Backup Retention Policy</title>
2820+
<title>Removing Redundant Backups</title>
28172821
<para>
28182822
By default, all backup copies created with <application>pg_probackup</application> are
28192823
stored in the specified backup catalog. To save disk space,
2820-
you can configure retention policy and periodically clean up
2821-
redundant backup copies accordingly.
2824+
you can configure retention policy to remove redundant backup copies.
28222825
</para>
28232826
<para>
28242827
To configure retention policy, set one or more of the
@@ -2841,56 +2844,51 @@ pg_probackup show -B <replaceable>backup_dir</replaceable> [--instance <replacea
28412844
<emphasis role="strong">the number of days</emphasis> from the
28422845
current moment. For example, if
28432846
<literal>retention-window=7</literal>, <application>pg_probackup</application> must
2844-
delete all backup copies that are older than seven days, with
2845-
all the corresponding WAL files.
2847+
keep at least one backup copy that is older than seven days, with
2848+
all the corresponding WAL files, and all the backups that follow.
28462849
</para>
28472850
<para>
28482851
If both <option>--retention-redundancy</option> and
2849-
<option>--retention-window</option> options are set,
2850-
<application>pg_probackup</application> keeps backup copies that satisfy at least one
2851-
condition. For example, if you set
2852-
<literal>--retention-redundancy=2</literal> and
2853-
<literal>--retention-window=7</literal>, <application>pg_probackup</application> purges
2854-
the backup catalog to keep only two full backup copies and all
2855-
backups that are newer than seven days:
2852+
<option>--retention-window</option> options are set, both these
2853+
conditions have to be taken into account when purging the backup
2854+
catalog. For example, if you set <literal>--retention-redundancy=2</literal>
2855+
and <literal>--retention-window=7</literal>,
2856+
<application>pg_probackup</application> has to keep two full backup
2857+
copies, as well as all the backups required to ensure recoverability
2858+
for the last seven days:
28562859
</para>
28572860
<programlisting>
28582861
pg_probackup set-config -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> --retention-redundancy=2 --retention-window=7
28592862
</programlisting>
2863+
2864+
<para>
2865+
To clean up the backup catalog in accordance with retention policy,
2866+
you have to run the <xref linkend="pbk-delete"/> command with
2867+
<link linkend="pbk-retention-opts">retention flags</link>, as shown
2868+
below, or use the <xref linkend="pbk-backup"/> command with
2869+
these flags to process the outdated backup copies right when the new
2870+
backup is created.
2871+
</para>
2872+
28602873
<para>
2861-
To clean up the backup catalog in accordance with retention
2862-
policy, run:
2874+
For example, to remove all backup copies that no longer satisfy the
2875+
defined retention policy, run the following command with the
2876+
<literal>--delete-expired</literal> flag:
28632877
</para>
28642878
<programlisting>
28652879
pg_probackup delete -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> --delete-expired
28662880
</programlisting>
2867-
<para>
2868-
<application>pg_probackup</application> deletes all backup copies that do not conform to
2869-
the defined retention policy.
2870-
</para>
28712881
<para>
28722882
If you would like to also remove the WAL files that are no
2873-
longer required for any of the backups, add the
2883+
longer required for any of the backups, you should also specify the
28742884
<option>--delete-wal</option> flag:
28752885
</para>
28762886
<programlisting>
28772887
pg_probackup delete -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> --delete-expired --delete-wal
28782888
</programlisting>
2879-
<note>
2880-
<para>
2881-
Alternatively, you can use the
2882-
<option>--delete-expired</option>,
2883-
<option>--merge-expired</option>,
2884-
<option>--delete-wal</option> flags and the
2885-
<option>--retention-window</option> and
2886-
<option>--retention-redundancy</option> options together
2887-
with the <xref linkend="pbk-backup"/> command to
2888-
remove and merge the outdated backup copies once the new
2889-
backup is created.
2890-
</para>
2891-
</note>
2889+
28922890
<para>
2893-
You can set or override the current retention policy by
2891+
You can also set or override the current retention policy by
28942892
specifying <option>--retention-redundancy</option> and
28952893
<option>--retention-window</option> options directly when
28962894
running <command>delete</command> or <command>backup</command>
@@ -2911,6 +2909,7 @@ pg_probackup delete -B <replaceable>backup_dir</replaceable> --instance <replace
29112909
<xref linkend="pbk-backup"/> or
29122910
<xref linkend="pbk-delete"/> commands.
29132911
</para>
2912+
29142913
<para>
29152914
Suppose you have backed up the <replaceable>node</replaceable>
29162915
instance in the <replaceable>backup_dir</replaceable> directory,
@@ -2963,9 +2962,10 @@ BACKUP INSTANCE 'node'
29632962
The <literal>Time</literal> field for the merged backup displays the time
29642963
required for the merge.
29652964
</para>
2965+
29662966
</refsect3>
29672967
<refsect3 id="pbk-backup-pinning">
2968-
<title>Backup Pinning</title>
2968+
<title>Pinning Backups</title>
29692969
<para>
29702970
If you need to keep certain backups longer than the
29712971
established retention policy allows, you can pin them
@@ -3004,8 +3004,8 @@ pg_probackup show -B <replaceable>backup_dir</replaceable> --instance <replaceab
30043004
</programlisting>
30053005
</para>
30063006
<para>
3007-
If the backup is pinned, the <literal>expire-time</literal>
3008-
attribute displays its expiration time:
3007+
If the backup is pinned, it has the <literal>expire-time</literal>
3008+
attribute that displays its expiration time:
30093009
<programlisting>
30103010
...
30113011
recovery-time = '2017-05-16 12:57:31'
@@ -3015,34 +3015,65 @@ data-bytes = 22288792
30153015
</programlisting>
30163016
</para>
30173017
<para>
3018-
Only pinned backups have the <literal>expire-time</literal>
3019-
attribute in the backup metadata.
3018+
You can unpin the backup by setting the <option>--ttl</option> option to zero:
30203019
</para>
3020+
<programlisting>
3021+
pg_probackup set-backup -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> -i <replaceable>backup_id</replaceable> --ttl=0
3022+
</programlisting>
3023+
30213024
<note>
30223025
<para>
30233026
A pinned incremental backup implicitly pins all
3024-
its parent backups.
3027+
its parent backups. If you unpin such a backup later,
3028+
its implicitly pinned parents will also be automatically unpinned.
30253029
</para>
30263030
</note>
3027-
<para>
3028-
You can unpin the backup by setting the
3029-
<option>--ttl</option> option to zero using the
3030-
<xref linkend="pbk-set-backup"/> command. For example:
3031-
</para>
3032-
<programlisting>
3033-
pg_probackup set-backup -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> -i <replaceable>backup_id</replaceable> --ttl=0
3034-
</programlisting>
30353031

30363032
</refsect3>
30373033
<refsect3 id="pbk-wal-archive-retention-policy">
3038-
<title>WAL Archive Retention Policy</title>
3034+
<title>Configuring WAL Archive Retention Policy</title>
3035+
<para>
3036+
When <link linkend="pbk-setting-up-continuous-wal-archiving">continuous
3037+
WAL archiving</link> is enabled, archived WAL segments can take a lot
3038+
of disk space. Even if you delete old backup copies from time to time,
3039+
the <literal>--delete-wal</literal> flag can
3040+
purge only those WAL segments that do not apply to any of the
3041+
remaining backups in the backup catalog. However, if point-in-time
3042+
recovery is critical only for the most recent backups, you can
3043+
configure WAL archive retention policy to keep WAL archive of
3044+
limited depth and win back some more disk space.
3045+
</para>
3046+
3047+
<para>
3048+
To configure WAL archive retention policy, you have to run the
3049+
<xref linkend="pbk-set-config"/> command with the
3050+
<literal>--wal-depth</literal> option that specifies the number
3051+
of backups that can be used for PITR.
3052+
This setting applies to all the timelines, so you should be able to perform
3053+
PITR for the same number of backups on each timeline, if available.
3054+
<link linkend="pbk-backup-pinning">Pinned backups</link> are
3055+
not included into this count: if one of the latest backups
3056+
is pinned, <application>pg_probackup</application> ensures that
3057+
PITR is possible for one extra backup.
3058+
</para>
3059+
30393060
<para>
3040-
By default, <application>pg_probackup</application> purges
3041-
only redundant WAL segments that cannot be applied to any of the
3042-
backups in the backup catalog. To save disk space,
3043-
you can configure WAL archive retention policy, which allows to
3044-
keep WAL of limited depth measured in backups per timeline.
3061+
To remove WAL segments that do not satisfy the defined WAL archive
3062+
retention policy, you simply have to run the <xref linkend="pbk-delete"/>
3063+
or <xref linkend="pbk-backup"/> command with the <literal>--delete-wal</literal>
3064+
flag. For archive backups, WAL segments between <literal>Start LSN</literal>
3065+
and <literal>Stop LSN</literal> are always kept intact, so such backups
3066+
remain valid regardless of the <literal>--wal-depth</literal> setting
3067+
and can still be restored, if required.
30453068
</para>
3069+
3070+
<para>
3071+
You can also use the <option>--wal-depth</option> option
3072+
with the <xref linkend="pbk-delete"/> and <xref linkend="pbk-backup"/>
3073+
commands to override the previously defined WAL archive retention
3074+
policy and purge old WAL segments on the fly.
3075+
</para>
3076+
30463077
<para>
30473078
Suppose you have backed up the <literal>node</literal>
30483079
instance in the <replaceable>backup_dir</replaceable> directory and
@@ -3096,8 +3127,8 @@ ARCHIVE INSTANCE 'node'
30963127
</programlisting>
30973128
<para>
30983129
If you would like, for example, to keep only those WAL
3099-
segments that can be applied to the last valid backup, use the
3100-
<option>--wal-depth</option> option:
3130+
segments that can be applied to the latest valid backup, set the
3131+
<option>--wal-depth</option> option to 1:
31013132
</para>
31023133
<programlisting>
31033134
pg_probackup delete -B <replaceable>backup_dir</replaceable> --instance node --delete-wal --wal-depth=1
@@ -3123,12 +3154,6 @@ ARCHIVE INSTANCE 'node'
31233154
===============================================================================================================================
31243155
1 0 0/0 000000010000000000000048 000000010000000000000049 1 72kB 228.00 7 OK
31253156
</programlisting>
3126-
<note>
3127-
<para>
3128-
<link linkend="pbk-backup-pinning">Pinned backups</link> are
3129-
ignored for the purpose of WAL Archive Retention Policy fulfilment.
3130-
</para>
3131-
</note>
31323157
</refsect3>
31333158
</refsect2>
31343159
<refsect2 id="pbk-merging-backups">
@@ -4130,7 +4155,7 @@ pg_probackup archive-get -B <replaceable>backup_dir</replaceable> --instance <re
41304155
The <literal>immediate</literal> value stops the recovery
41314156
after reaching the consistent state of the specified
41324157
backup, or the latest available backup if the
4133-
<option>-i</option>/<option>--backup_id</option> option is omitted.
4158+
<option>-i</option>/<option>--backup-id</option> option is omitted.
41344159
This is the default behavior for STREAM backups.
41354160
</para>
41364161
</listitem>

0 commit comments

Comments
 (0)