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

Commitfcaae1a

Browse files
author
Michael Paquier
committed
Allow only one keep parameter to trigger backup deletion
Having files satisfying both conditions seems somewhat awkward, as userswould usually choose either the number of generations to keep or theamount of days to keep the files. Hence deletion of a backup is bypassedonly when both parameters are set to infinite.At the same time correct some typos and incorrections in the deletioncode.
1 parentcb939f6 commitfcaae1a

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

‎delete.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,22 @@ do_delete(pgBackupRange *range, bool force)
2525
if (!pgBackupRangeIsValid(range))
2626
elog(ERROR_ARGS,_("required delete range option not specified: delete DATE"));
2727

28-
/*get exclusive lock of backup catalog */
28+
/*Lock backup catalog */
2929
ret=catalog_lock();
3030
if (ret==-1)
3131
elog(ERROR_SYSTEM,_("can't lock backup catalog."));
3232
elseif (ret==1)
3333
elog(ERROR_ALREADY_RUNNING,
3434
_("another pg_rman is running, stop delete."));
3535

36-
/*getlist ofbackups. */
36+
/*Get completelist ofbackup */
3737
backup_list=catalog_get_backup_list(NULL);
38-
if(!backup_list){
39-
elog(ERROR_SYSTEM,_("can't process any more."));
40-
}
38+
if (!backup_list)
39+
elog(ERROR_SYSTEM,_("No backup list found, can't process any more."));
4140

41+
/* Find backups to be deleted */
4242
do_delete= false;
4343
force_delete= false;
44-
/* find delete target backup. */
4544
for (i=0;i<parray_num(backup_list);i++)
4645
{
4746
pgBackup*backup= (pgBackup*)parray_get(backup_list,i);
@@ -60,7 +59,7 @@ do_delete(pgBackupRange *range, bool force)
6059
continue;
6160
}
6261

63-
/*findlatest full backup. */
62+
/*Found thelatest full backup */
6463
if (backup->backup_mode >=BACKUP_MODE_FULL&&
6564
backup->status==BACKUP_STATUS_OK&&
6665
backup->start_time <=range->begin)
@@ -111,45 +110,45 @@ pgBackupDelete(int keep_generations, int keep_days)
111110
generations_str,days_str);
112111
}
113112

114-
/*delete files which satisfy both condition */
115-
if (keep_generations==KEEP_INFINITE||keep_days==KEEP_INFINITE)
113+
/*Leave if an infinite generation of backups is kept */
114+
if (keep_generations==KEEP_INFINITE&&keep_days==KEEP_INFINITE)
116115
{
117116
elog(LOG,"%s() infinite",__FUNCTION__);
118117
return;
119118
}
120119

121-
/*get list of backups. */
120+
/*Get a complete list of backups. */
122121
backup_list=catalog_get_backup_list(NULL);
123122

123+
/* Find target backups to be deleted */
124124
backup_num=0;
125-
/* find delete target backup. */
126125
for (i=0;i<parray_num(backup_list);i++)
127126
{
128127
pgBackup*backup= (pgBackup*)parray_get(backup_list,i);
129128

130129
elog(LOG,"%s() %lu",__FUNCTION__,backup->start_time);
130+
131131
/*
132-
*whenvalidate full backup was found, we can delete the backup
133-
* that is older than it
132+
*When avalidate full backup was found, we can delete the
133+
*backupthat is older than it.
134134
*/
135135
if (backup->backup_mode >=BACKUP_MODE_FULL&&
136136
backup->status==BACKUP_STATUS_OK)
137137
backup_num++;
138138

139-
/* do not include the latest full backup in a count. */
140-
//if (backup_num - 1 <= keep_generations)
139+
/* Evaluate if this backup is eligible for removal */
141140
if (backup_num <=keep_generations)
142141
{
142+
/* Do not include the latest full backup in this count */
143143
elog(LOG,"%s() backup are only %d",__FUNCTION__,backup_num);
144144
continue;
145145
}
146-
147-
/*
148-
* If the start time of the backup is older than the threshold and
149-
* there are enough generations of full backups, delete the backup.
150-
*/
151-
if (backup->start_time >=days_threshold)
146+
elseif (backup->start_time >=days_threshold)
152147
{
148+
/*
149+
* If the start time of the backup is older than the threshold and
150+
* there are enough generations of full backups, delete the backup.
151+
*/
153152
elog(LOG,"%s() %lu is not older than %lu",__FUNCTION__,
154153
backup->start_time,days_threshold);
155154
continue;

‎pg_rman.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ absolute paths; relative paths are not allowed.
257257
Specify how long backuped data files will be kept.
258258
--keep-data-generations means number of backup generations.
259259
--keep-data-days means days to be kept.
260-
Only files exceededbothsettings are deleted.
260+
Only files exceededone of thosesettings are deleted.
261261

262262
--keep-arclog-files / --keep-arclog-days
263263
Specify how long backuped archive WAL files will be kept.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp