@@ -209,19 +209,24 @@ do_restore_or_validate(time_t target_backup_id,
209209
210210 /*
211211 * Validate backups from base_full_backup to dest_backup.
212- * And restore if subcommand is RESTORE.
213- * TODO what if we found out that backup is not valid?
214212 */
215213 for (i = base_full_backup_index ; i >= dest_backup_index ; i -- )
216214 {
217215 pgBackup * backup = (pgBackup * ) parray_get (backups , i );
216+ pgBackupValidate (backup );
217+ }
218218
219- if (backup -> status == BACKUP_STATUS_OK )
219+ /* We ensured that all backups are valid, now restore if required */
220+ if (is_restore )
221+ {
222+ for (i = base_full_backup_index ; i >= dest_backup_index ; i -- )
220223 {
221- pgBackupValidate (backup );
222-
223- if (is_restore )
224+ pgBackup * backup = (pgBackup * ) parray_get (backups , i );
225+ if (backup -> status == BACKUP_STATUS_OK )
224226 restore_backup (backup );
227+ else
228+ elog (ERROR , "backup %s is not valid" ,
229+ base36enc (backup -> start_time ));
225230 }
226231 }
227232
@@ -548,9 +553,8 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
548553 * Check that all tablespace mapping entries have correct linked directory
549554 * paths. Linked directories must be empty or do not exist.
550555 *
551- * If tablespace-mapping option is supplied all OLDDIR entries should have
556+ * If tablespace-mapping option is supplied, all OLDDIR entries must have
552557 * entries in tablespace_map file.
553- * TODO review
554558 */
555559static void
556560check_tablespace_mapping (pgBackup * backup )
@@ -568,7 +572,7 @@ check_tablespace_mapping(pgBackup *backup)
568572
569573 elog (LOG , "check tablespace directories of backup %s" , base36enc (backup -> start_time ));
570574
571- /* 1 - OLDDIR should has an entry in links */
575+ /* 1 - each OLDDIR must have an entry in tablespace_map file ( links) */
572576 for (cell = tablespace_dirs .head ; cell ; cell = cell -> next )
573577 {
574578 tmp_file -> linked = cell -> old_dir ;
@@ -579,7 +583,7 @@ check_tablespace_mapping(pgBackup *backup)
579583 cell -> old_dir );
580584 }
581585
582- /* 2 - all linked directories should be empty */
586+ /* 2 - all linked directories must be empty */
583587 for (i = 0 ; i < parray_num (links ); i ++ )
584588 {
585589 pgFile * link = (pgFile * ) parray_get (links , i );
0 commit comments