1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-02-08 14:28:36 +02:00

Fix old backup removal for specified number of days

Backups could be removed even if generation number was set to infinite
without caring of the day threashold calculated. Backups are removed
if they either satisfy the generation or the day threshold.
This commit is contained in:
Michael Paquier 2014-01-10 08:40:39 +09:00
parent 3d0a22308c
commit 1c3512fadf
3 changed files with 11 additions and 7 deletions

View File

@ -1379,13 +1379,15 @@ delete_old_files(const char *root,
* If the mtime of the file is older than the threshold and there are
* enough number of files newer than the files, delete the file.
*/
if (file->mtime >= days_threshold)
if (file->mtime >= days_threshold &&
keep_days != KEEP_INFINITE)
{
elog(LOG, "%s() %lu is not older than %lu", __FUNCTION__,
file->mtime, days_threshold);
continue;
}
else if (file_num <= keep_files)
else if (file_num <= keep_files &&
keep_files != KEEP_INFINITE)
{
elog(LOG, "%s() newer files are only %d", __FUNCTION__, file_num);
continue;

View File

@ -129,13 +129,15 @@ pgBackupDelete(int keep_generations, int keep_days)
backup_num++;
/* Evaluate if this backup is eligible for removal */
if (backup_num <= keep_generations)
if (backup_num <= keep_generations &&
keep_generations != KEEP_INFINITE)
{
/* Do not include the latest full backup in this count */
elog(LOG, "%s() backup are only %d", __FUNCTION__, backup_num);
continue;
}
else if (backup->start_time >= days_threshold)
else if (backup->start_time >= days_threshold &&
keep_days != KEEP_INFINITE)
{
/*
* If the start time of the backup is older than the threshold and

View File

@ -29,11 +29,11 @@ CHECKPOINT
# of recovery target option in recovery.conf
3
# of deleted backups (show all)
3
4
# of deleted backups
0
delete backup
# of deleted backups
3
4
# of deleted backups
8
9