Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b799b70

Browse files
committed
Merge branch 'issue_106'
2 parents 8b15753 + 738013f commit b799b70

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/delete.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
259259
{
260260

261261
bool redundancy_keep = false;
262+
time_t backup_time = 0;
262263
pgBackup *backup = (pgBackup *) parray_get(backup_list, (size_t) i);
263264

264265
/* check if backup`s FULL ancestor is in redundancy list */
@@ -280,10 +281,16 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
280281
cur_full_backup_num++;
281282
}
282283

283-
/* Check if backup in needed by retention policy
284-
* TODO: consider that ERROR backup most likely to have recovery_time == 0
284+
/* Invalid and running backups most likely to have recovery_time == 0,
285+
* so in this case use start_time instead.
285286
*/
286-
if ((days_threshold == 0 || (days_threshold > backup->recovery_time)) &&
287+
if (backup->recovery_time)
288+
backup_time = backup->recovery_time;
289+
else
290+
backup_time = backup->start_time;
291+
292+
/* Check if backup in needed by retention policy */
293+
if ((days_threshold == 0 || (days_threshold > backup_time)) &&
287294
(instance_config.retention_redundancy == 0 || !redundancy_keep))
288295
{
289296
/* This backup is not guarded by retention

0 commit comments

Comments
 (0)