Skip to content

Commit 316f0d2

Browse files
committed
[Issue #328] Do not delete invalid full backups within retention redundancy range
1 parent 04bab3e commit 316f0d2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/delete.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,14 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
227227
{
228228
pgBackup *backup = (pgBackup *) parray_get(backup_list, i);
229229

230-
/* Consider only valid FULL backups for Redundancy */
231-
if (instance_config.retention_redundancy > 0 &&
232-
backup->backup_mode == BACKUP_MODE_FULL &&
233-
(backup->status == BACKUP_STATUS_OK ||
234-
backup->status == BACKUP_STATUS_DONE))
230+
if (backup->backup_mode == BACKUP_MODE_FULL)
235231
{
236-
n_full_backups++;
232+
/* Consider only valid FULL backups for Redundancy fulfillment */
233+
if (backup->status == BACKUP_STATUS_OK ||
234+
backup->status == BACKUP_STATUS_DONE)
235+
{
236+
n_full_backups++;
237+
}
237238

238239
/* Add every FULL backup that satisfy Redundancy policy to separate list */
239240
if (n_full_backups <= instance_config.retention_redundancy)
@@ -413,7 +414,10 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
413414
pinning_window ? pinning_window : instance_config.retention_window,
414415
action);
415416

416-
if (backup->backup_mode == BACKUP_MODE_FULL)
417+
/* Only valid full backups are count to something */
418+
if (backup->backup_mode == BACKUP_MODE_FULL &&
419+
(backup->status == BACKUP_STATUS_OK ||
420+
backup->status == BACKUP_STATUS_DONE))
417421
cur_full_backup_num++;
418422
}
419423
}

0 commit comments

Comments
 (0)