@@ -122,7 +122,7 @@ do_restore_or_validate(time_t target_backup_id,
122
122
timelines = readTimeLineHistory_probackup (target_tli );
123
123
}
124
124
125
- /* Find backup range we should restore. */
125
+ /* Find backup range we should restore or validate . */
126
126
for (i = 0 ; i < parray_num (backups ); i ++ )
127
127
{
128
128
current_backup = (pgBackup * ) parray_get (backups , i );
@@ -217,40 +217,42 @@ do_restore_or_validate(time_t target_backup_id,
217
217
pgBackupValidate (backup );
218
218
}
219
219
220
+ /*
221
+ * Validate corresponding WAL files.
222
+ * TODO Shouldn't we pass recovery_target_timeline as last argument?
223
+ */
224
+ validate_wal (dest_backup , arclog_path , rt -> recovery_target_time ,
225
+ rt -> recovery_target_xid , base_full_backup -> tli );
226
+
227
+
220
228
/* We ensured that all backups are valid, now restore if required */
221
229
if (is_restore )
222
230
{
231
+ pgBackup * backup ;
223
232
for (i = base_full_backup_index ; i >= dest_backup_index ; i -- )
224
233
{
225
- pgBackup * backup = (pgBackup * ) parray_get (backups , i );
234
+ backup = (pgBackup * ) parray_get (backups , i );
226
235
if (backup -> status == BACKUP_STATUS_OK )
227
236
restore_backup (backup );
228
237
else
229
238
elog (ERROR , "backup %s is not valid" ,
230
239
base36enc (backup -> start_time ));
231
240
}
232
- }
233
241
234
- /*
235
- * Delete files which are not in dest backup file list. Files which were
236
- * deleted between previous and current backup are not in the list.
237
- */
238
- if (is_restore )
239
- {
240
- pgBackup * dest_backup = (pgBackup * ) parray_get (backups , dest_backup_index );
242
+ /*
243
+ * Delete files which are not in dest backup file list. Files which were
244
+ * deleted between previous and current backup are not in the list.
245
+ */
241
246
if (dest_backup -> backup_mode != BACKUP_MODE_FULL )
242
247
remove_deleted_files (dest_backup );
243
- }
244
248
245
- if (! dest_backup -> stream
246
- || ( target_time != NULL || target_xid != NULL ))
247
- {
248
- if ( is_restore )
249
+ /* TODO Add comment */
250
+ if (! dest_backup -> stream
251
+ || ( target_time != NULL || target_xid != NULL ))
252
+ {
249
253
create_recovery_conf (target_backup_id , target_time , target_xid ,
250
254
target_inclusive , target_tli );
251
- else
252
- validate_wal (dest_backup , arclog_path , rt -> recovery_target_time ,
253
- rt -> recovery_target_xid , base_full_backup -> tli );
255
+ }
254
256
}
255
257
256
258
/* cleanup */
0 commit comments