@@ -110,6 +110,16 @@ do_delete(time_t backup_id)
110
110
parray_free (backup_list );
111
111
}
112
112
113
+ /*
114
+ * Merge and purge backups by retention policy. Retention policy is configured by
115
+ * retention_redundancy and retention_window variables.
116
+ *
117
+ * Invalid backups handled in Oracle style, so invalid backups are ignored
118
+ * for the purpose of retention fulfillment,
119
+ * i.e. CORRUPT full backup do not taken in account when deteremine
120
+ * which FULL backup should be keeped for redundancy obligation(only valid do),
121
+ * but if invalid backup is not guarded by retention - it is removed
122
+ */
113
123
int do_retention (void )
114
124
{
115
125
parray * backup_list = NULL ;
@@ -122,7 +132,6 @@ int do_retention(void)
122
132
/* Get a complete list of backups. */
123
133
backup_list = catalog_get_backup_list (INVALID_BACKUP_ID );
124
134
125
- /* sanity */
126
135
if (parray_num (backup_list ) == 0 )
127
136
backup_list_is_empty = true;
128
137
@@ -136,14 +145,13 @@ int do_retention(void)
136
145
if (instance_config .retention_redundancy == 0 &&
137
146
instance_config .retention_window == 0 )
138
147
{
139
- /* Retention is disabled but we still can cleanup wal
140
- */
148
+ /* Retention is disabled but we still can cleanup wal */
141
149
elog (WARNING , "Retention policy is not set" );
142
150
if (!delete_wal )
143
151
return 0 ;
144
152
}
145
153
else
146
- /* At least one retention policy is active */
154
+ /* At least one retention policy is active */
147
155
retention_is_set = true;
148
156
}
149
157
@@ -182,15 +190,9 @@ int do_retention(void)
182
190
183
191
}
184
192
185
- /*
186
- * Merge and purge backups by retention policy. Retention policy is configured by
187
- * retention_redundancy and retention_window variables.
188
- *
189
- * Invalid backups handled in Oracle style, so invalid backups are ignored
190
- * for the purpose of retention fulfillment,
191
- * i.e. CORRUPT full backup do not taken in account when deteremine
192
- * which FULL backup should be keeped for redundancy obligation(only valid do),
193
- * but if invalid backup is not guarded by retention - it is removed
193
+ /* Evaluate every backup by retention policies and populate purge and keep lists.
194
+ * Also for every backup print proposed action('Active' or 'Expired') according
195
+ * to active retention policies.
194
196
*/
195
197
static void
196
198
do_retention_internal (parray * backup_list , parray * to_keep_list , parray * to_purge_list )
@@ -326,12 +328,12 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
326
328
cur_full_backup_num = 1 ;
327
329
for (i = 0 ; i < parray_num (backup_list ); i ++ )
328
330
{
329
- char * action = "Keep " ;
331
+ char * action = "Active " ;
330
332
331
333
pgBackup * backup = (pgBackup * ) parray_get (backup_list , i );
332
334
333
335
if (parray_bsearch (to_purge_list , backup , pgBackupCompareIdDesc ))
334
- action = "Purge " ;
336
+ action = "Expired " ;
335
337
336
338
if (backup -> recovery_time == 0 )
337
339
actual_window = 0 ;
@@ -352,6 +354,7 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
352
354
}
353
355
}
354
356
357
+ /* Merge partially expired incremental chains */
355
358
static void
356
359
do_retention_merge (parray * backup_list , parray * to_keep_list , parray * to_purge_list )
357
360
{
@@ -494,6 +497,7 @@ do_retention_merge(parray *backup_list, parray *to_keep_list, parray *to_purge_l
494
497
495
498
}
496
499
500
+ /* Purge expired backups */
497
501
static void
498
502
do_retention_purge (parray * to_keep_list , parray * to_purge_list )
499
503
{
0 commit comments