@@ -25,23 +25,22 @@ do_delete(pgBackupRange *range, bool force)
2525if (!pgBackupRangeIsValid (range ))
2626elog (ERROR_ARGS ,_ ("required delete range option not specified: delete DATE" ));
2727
28- /*get exclusive lock of backup catalog */
28+ /*Lock backup catalog */
2929ret = catalog_lock ();
3030if (ret == -1 )
3131elog (ERROR_SYSTEM ,_ ("can't lock backup catalog." ));
3232else if (ret == 1 )
3333elog (ERROR_ALREADY_RUNNING ,
3434_ ("another pg_rman is running, stop delete." ));
3535
36- /*get list ofbackups. */
36+ /*Get complete list ofbackup */
3737backup_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 */
4242do_delete = false;
4343force_delete = false;
44- /* find delete target backup. */
4544for (i = 0 ;i < parray_num (backup_list );i ++ )
4645{
4746pgBackup * backup = (pgBackup * )parray_get (backup_list ,i );
@@ -60,7 +59,7 @@ do_delete(pgBackupRange *range, bool force)
6059continue ;
6160}
6261
63- /*find latest full backup. */
62+ /*Found the latest full backup */
6463if (backup -> backup_mode >=BACKUP_MODE_FULL &&
6564backup -> status == BACKUP_STATUS_OK &&
6665backup -> start_time <=range -> begin )
@@ -111,45 +110,45 @@ pgBackupDelete(int keep_generations, int keep_days)
111110generations_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{
117116elog (LOG ,"%s() infinite" ,__FUNCTION__ );
118117return ;
119118}
120119
121- /*get list of backups. */
120+ /*Get a complete list of backups. */
122121backup_list = catalog_get_backup_list (NULL );
123122
123+ /* Find target backups to be deleted */
124124backup_num = 0 ;
125- /* find delete target backup. */
126125for (i = 0 ;i < parray_num (backup_list );i ++ )
127126{
128127pgBackup * backup = (pgBackup * )parray_get (backup_list ,i );
129128
130129elog (LOG ,"%s() %lu" ,__FUNCTION__ ,backup -> start_time );
130+
131131/*
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.
134134 */
135135if (backup -> backup_mode >=BACKUP_MODE_FULL &&
136136backup -> status == BACKUP_STATUS_OK )
137137backup_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 */
141140if (backup_num <=keep_generations )
142141{
142+ /* Do not include the latest full backup in this count */
143143elog (LOG ,"%s() backup are only %d" ,__FUNCTION__ ,backup_num );
144144continue ;
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+ else if (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+ */
153152elog (LOG ,"%s() %lu is not older than %lu" ,__FUNCTION__ ,
154153backup -> start_time ,days_threshold );
155154continue ;