Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c3512f

Browse files
author
Michael Paquier
committed
Fix old backup removal for specified number of days
Backups could be removed even if generation number was set to infinitewithout caring of the day threashold calculated. Backups are removedif they either satisfy the generation or the day threshold.
1 parent3d0a223 commit1c3512f

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

‎backup.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,13 +1379,15 @@ delete_old_files(const char *root,
13791379
* If the mtime of the file is older than the threshold and there are
13801380
* enough number of files newer than the files, delete the file.
13811381
*/
1382-
if (file->mtime >=days_threshold)
1382+
if (file->mtime >=days_threshold&&
1383+
keep_days!=KEEP_INFINITE)
13831384
{
13841385
elog(LOG,"%s() %lu is not older than %lu",__FUNCTION__,
13851386
file->mtime,days_threshold);
13861387
continue;
13871388
}
1388-
elseif (file_num <=keep_files)
1389+
elseif (file_num <=keep_files&&
1390+
keep_files!=KEEP_INFINITE)
13891391
{
13901392
elog(LOG,"%s() newer files are only %d",__FUNCTION__,file_num);
13911393
continue;

‎delete.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@ pgBackupDelete(int keep_generations, int keep_days)
129129
backup_num++;
130130

131131
/* Evaluate if this backup is eligible for removal */
132-
if (backup_num <=keep_generations)
132+
if (backup_num <=keep_generations&&
133+
keep_generations!=KEEP_INFINITE)
133134
{
134135
/* Do not include the latest full backup in this count */
135136
elog(LOG,"%s() backup are only %d",__FUNCTION__,backup_num);
136137
continue;
137138
}
138-
elseif (backup->start_time >=days_threshold)
139+
elseif (backup->start_time >=days_threshold&&
140+
keep_days!=KEEP_INFINITE)
139141
{
140142
/*
141143
* If the start time of the backup is older than the threshold and

‎expected/backup_restore.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ CHECKPOINT
2929
# of recovery target option in recovery.conf
3030
3
3131
# of deleted backups (show all)
32-
3
32+
4
3333
# of deleted backups
3434
0
3535
delete backup
3636
# of deleted backups
37-
3
37+
4
3838
# of deleted backups
39-
8
39+
9

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp