@@ -1475,7 +1475,7 @@ pg_probackup checkdb [-B <replaceable>backup_dir</replaceable> [--instance <repl
1475
1475
enough to specify the backup instance of this cluster for
1476
1476
<application >pg_probackup</application > to determine the required
1477
1477
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
1479
1479
<link linkend =" pbk-connection-opts" >connection options</link > and
1480
1480
<replaceable >data_dir</replaceable > via environment
1481
1481
variables or command-line options.
@@ -2364,7 +2364,8 @@ primary_conninfo = 'user=backup passfile=/var/lib/pgsql/.pgpass port=5432 sslmod
2364
2364
<listitem >
2365
2365
<para >
2366
2366
<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.
2368
2369
</para >
2369
2370
</listitem >
2370
2371
<listitem >
@@ -2808,17 +2809,19 @@ pg_probackup show -B <replaceable>backup_dir</replaceable> [--instance <replacea
2808
2809
<refsect2 id =" pbk-configuring-retention-policy" >
2809
2810
<title >Configuring Retention Policy</title >
2810
2811
<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.
2814
2817
</para >
2818
+
2815
2819
<refsect3 id =" pbk-retention-policy" >
2816
- <title >Backup Retention Policy </title >
2820
+ <title >Removing Redundant Backups </title >
2817
2821
<para >
2818
2822
By default, all backup copies created with <application >pg_probackup</application > are
2819
2823
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.
2822
2825
</para >
2823
2826
<para >
2824
2827
To configure retention policy, set one or more of the
@@ -2841,56 +2844,51 @@ pg_probackup show -B <replaceable>backup_dir</replaceable> [--instance <replacea
2841
2844
<emphasis role =" strong" >the number of days</emphasis > from the
2842
2845
current moment. For example, if
2843
2846
<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 .
2846
2849
</para >
2847
2850
<para >
2848
2851
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:
2856
2859
</para >
2857
2860
<programlisting >
2858
2861
pg_probackup set-config -B <replaceable >backup_dir</replaceable > --instance <replaceable >instance_name</replaceable > --retention-redundancy=2 --retention-window=7
2859
2862
</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
+
2860
2873
<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:
2863
2877
</para >
2864
2878
<programlisting >
2865
2879
pg_probackup delete -B <replaceable >backup_dir</replaceable > --instance <replaceable >instance_name</replaceable > --delete-expired
2866
2880
</programlisting >
2867
- <para >
2868
- <application >pg_probackup</application > deletes all backup copies that do not conform to
2869
- the defined retention policy.
2870
- </para >
2871
2881
<para >
2872
2882
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
2874
2884
<option >--delete-wal</option > flag:
2875
2885
</para >
2876
2886
<programlisting >
2877
2887
pg_probackup delete -B <replaceable >backup_dir</replaceable > --instance <replaceable >instance_name</replaceable > --delete-expired --delete-wal
2878
2888
</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
+
2892
2890
<para >
2893
- You can set or override the current retention policy by
2891
+ You can also set or override the current retention policy by
2894
2892
specifying <option >--retention-redundancy</option > and
2895
2893
<option >--retention-window</option > options directly when
2896
2894
running <command >delete</command > or <command >backup</command >
@@ -2911,6 +2909,7 @@ pg_probackup delete -B <replaceable>backup_dir</replaceable> --instance <replace
2911
2909
<xref linkend =" pbk-backup" /> or
2912
2910
<xref linkend =" pbk-delete" /> commands.
2913
2911
</para >
2912
+
2914
2913
<para >
2915
2914
Suppose you have backed up the <replaceable >node</replaceable >
2916
2915
instance in the <replaceable >backup_dir</replaceable > directory,
@@ -2963,9 +2962,10 @@ BACKUP INSTANCE 'node'
2963
2962
The <literal >Time</literal > field for the merged backup displays the time
2964
2963
required for the merge.
2965
2964
</para >
2965
+
2966
2966
</refsect3 >
2967
2967
<refsect3 id =" pbk-backup-pinning" >
2968
- <title >Backup Pinning</title >
2968
+ <title >Pinning Backups </title >
2969
2969
<para >
2970
2970
If you need to keep certain backups longer than the
2971
2971
established retention policy allows, you can pin them
@@ -3004,8 +3004,8 @@ pg_probackup show -B <replaceable>backup_dir</replaceable> --instance <replaceab
3004
3004
</programlisting >
3005
3005
</para >
3006
3006
<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:
3009
3009
<programlisting >
3010
3010
...
3011
3011
recovery-time = '2017-05-16 12:57:31'
@@ -3015,34 +3015,65 @@ data-bytes = 22288792
3015
3015
</programlisting >
3016
3016
</para >
3017
3017
<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:
3020
3019
</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
+
3021
3024
<note >
3022
3025
<para >
3023
3026
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.
3025
3029
</para >
3026
3030
</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 >
3035
3031
3036
3032
</refsect3 >
3037
3033
<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
+
3039
3060
<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.
3045
3068
</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
+
3046
3077
<para >
3047
3078
Suppose you have backed up the <literal >node</literal >
3048
3079
instance in the <replaceable >backup_dir</replaceable > directory and
@@ -3096,8 +3127,8 @@ ARCHIVE INSTANCE 'node'
3096
3127
</programlisting >
3097
3128
<para >
3098
3129
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 :
3101
3132
</para >
3102
3133
<programlisting >
3103
3134
pg_probackup delete -B <replaceable >backup_dir</replaceable > --instance node --delete-wal --wal-depth=1
@@ -3123,12 +3154,6 @@ ARCHIVE INSTANCE 'node'
3123
3154
===============================================================================================================================
3124
3155
1 0 0/0 000000010000000000000048 000000010000000000000049 1 72kB 228.00 7 OK
3125
3156
</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 >
3132
3157
</refsect3 >
3133
3158
</refsect2 >
3134
3159
<refsect2 id =" pbk-merging-backups" >
@@ -4130,7 +4155,7 @@ pg_probackup archive-get -B <replaceable>backup_dir</replaceable> --instance <re
4130
4155
The <literal >immediate</literal > value stops the recovery
4131
4156
after reaching the consistent state of the specified
4132
4157
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.
4134
4159
This is the default behavior for STREAM backups.
4135
4160
</para >
4136
4161
</listitem >
0 commit comments