@@ -25,23 +25,22 @@ do_delete(pgBackupRange *range, bool force)
25
25
if (!pgBackupRangeIsValid (range ))
26
26
elog (ERROR_ARGS ,_ ("required delete range option not specified: delete DATE" ));
27
27
28
- /*get exclusive lock of backup catalog */
28
+ /*Lock backup catalog */
29
29
ret = catalog_lock ();
30
30
if (ret == -1 )
31
31
elog (ERROR_SYSTEM ,_ ("can't lock backup catalog." ));
32
32
else if (ret == 1 )
33
33
elog (ERROR_ALREADY_RUNNING ,
34
34
_ ("another pg_rman is running, stop delete." ));
35
35
36
- /*get list ofbackups. */
36
+ /*Get complete list ofbackup */
37
37
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." ));
41
40
41
+ /* Find backups to be deleted */
42
42
do_delete = false;
43
43
force_delete = false;
44
- /* find delete target backup. */
45
44
for (i = 0 ;i < parray_num (backup_list );i ++ )
46
45
{
47
46
pgBackup * backup = (pgBackup * )parray_get (backup_list ,i );
@@ -60,7 +59,7 @@ do_delete(pgBackupRange *range, bool force)
60
59
continue ;
61
60
}
62
61
63
- /*find latest full backup. */
62
+ /*Found the latest full backup */
64
63
if (backup -> backup_mode >=BACKUP_MODE_FULL &&
65
64
backup -> status == BACKUP_STATUS_OK &&
66
65
backup -> start_time <=range -> begin )
@@ -111,45 +110,45 @@ pgBackupDelete(int keep_generations, int keep_days)
111
110
generations_str ,days_str );
112
111
}
113
112
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 )
116
115
{
117
116
elog (LOG ,"%s() infinite" ,__FUNCTION__ );
118
117
return ;
119
118
}
120
119
121
- /*get list of backups. */
120
+ /*Get a complete list of backups. */
122
121
backup_list = catalog_get_backup_list (NULL );
123
122
123
+ /* Find target backups to be deleted */
124
124
backup_num = 0 ;
125
- /* find delete target backup. */
126
125
for (i = 0 ;i < parray_num (backup_list );i ++ )
127
126
{
128
127
pgBackup * backup = (pgBackup * )parray_get (backup_list ,i );
129
128
130
129
elog (LOG ,"%s() %lu" ,__FUNCTION__ ,backup -> start_time );
130
+
131
131
/*
132
- *when validate full backup was found, we can delete the backup
133
- * that is older than it
132
+ *When a validate full backup was found, we can delete the
133
+ *backup that is older than it.
134
134
*/
135
135
if (backup -> backup_mode >=BACKUP_MODE_FULL &&
136
136
backup -> status == BACKUP_STATUS_OK )
137
137
backup_num ++ ;
138
138
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 */
141
140
if (backup_num <=keep_generations )
142
141
{
142
+ /* Do not include the latest full backup in this count */
143
143
elog (LOG ,"%s() backup are only %d" ,__FUNCTION__ ,backup_num );
144
144
continue ;
145
145
}
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
+ else if (backup -> start_time >=days_threshold )
152
147
{
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
+ */
153
152
elog (LOG ,"%s() %lu is not older than %lu" ,__FUNCTION__ ,
154
153
backup -> start_time ,days_threshold );
155
154
continue ;