@@ -243,66 +243,69 @@ do_restore_or_validate(time_t target_backup_id,
243
243
if (is_restore )
244
244
check_tablespace_mapping (dest_backup );
245
245
246
- if (dest_backup -> backup_mode != BACKUP_MODE_FULL )
247
- elog (INFO , "Validating parents for backup %s" , base36enc (dest_backup -> start_time ));
248
-
249
- /*
250
- * Validate backups from base_full_backup to dest_backup.
251
- */
252
- for (i = base_full_backup_index ; i >= dest_backup_index ; i -- )
246
+ if (!is_restore || !rt -> restore_no_validate )
253
247
{
254
- pgBackup * backup = (pgBackup * ) parray_get (backups , i );
255
- pgBackupValidate (backup );
256
- /* Maybe we should be more paranoid and check for !BACKUP_STATUS_OK? */
257
- if (backup -> status == BACKUP_STATUS_CORRUPT )
258
- {
259
- corrupted_backup = backup ;
260
- corrupted_backup_index = i ;
261
- break ;
262
- }
263
- /* We do not validate WAL files of intermediate backups
264
- * It`s done to speed up restore
265
- */
266
- }
267
- /* There is no point in wal validation
268
- * if there is corrupted backup between base_backup and dest_backup
269
- */
270
- if (!corrupted_backup )
248
+ if (dest_backup -> backup_mode != BACKUP_MODE_FULL )
249
+ elog (INFO , "Validating parents for backup %s" , base36enc (dest_backup -> start_time ));
250
+
271
251
/*
272
- * Validate corresponding WAL files.
273
- * We pass base_full_backup timeline as last argument to this function,
274
- * because it's needed to form the name of xlog file.
252
+ * Validate backups from base_full_backup to dest_backup.
275
253
*/
276
- validate_wal (dest_backup , arclog_path , rt -> recovery_target_time ,
277
- rt -> recovery_target_xid , base_full_backup -> tli );
278
-
279
- /* Set every incremental backup between corrupted backup and nearest FULL backup as orphans */
280
- if (corrupted_backup )
281
- {
282
- for (i = corrupted_backup_index - 1 ; i >= 0 ; i -- )
254
+ for (i = base_full_backup_index ; i >= dest_backup_index ; i -- )
283
255
{
284
256
pgBackup * backup = (pgBackup * ) parray_get (backups , i );
285
- /* Mark incremental OK backup as orphan */
286
- if (backup -> backup_mode == BACKUP_MODE_FULL )
257
+ pgBackupValidate (backup );
258
+ /* Maybe we should be more paranoid and check for !BACKUP_STATUS_OK? */
259
+ if (backup -> status == BACKUP_STATUS_CORRUPT )
260
+ {
261
+ corrupted_backup = backup ;
262
+ corrupted_backup_index = i ;
287
263
break ;
288
- if (backup -> status != BACKUP_STATUS_OK )
289
- continue ;
290
- else
264
+ }
265
+ /* We do not validate WAL files of intermediate backups
266
+ * It`s done to speed up restore
267
+ */
268
+ }
269
+ /* There is no point in wal validation
270
+ * if there is corrupted backup between base_backup and dest_backup
271
+ */
272
+ if (!corrupted_backup )
273
+ /*
274
+ * Validate corresponding WAL files.
275
+ * We pass base_full_backup timeline as last argument to this function,
276
+ * because it's needed to form the name of xlog file.
277
+ */
278
+ validate_wal (dest_backup , arclog_path , rt -> recovery_target_time ,
279
+ rt -> recovery_target_xid , base_full_backup -> tli );
280
+
281
+ /* Set every incremental backup between corrupted backup and nearest FULL backup as orphans */
282
+ if (corrupted_backup )
283
+ {
284
+ for (i = corrupted_backup_index - 1 ; i >= 0 ; i -- )
291
285
{
292
- char * backup_id ,
293
- * corrupted_backup_id ;
286
+ pgBackup * backup = (pgBackup * ) parray_get (backups , i );
287
+ /* Mark incremental OK backup as orphan */
288
+ if (backup -> backup_mode == BACKUP_MODE_FULL )
289
+ break ;
290
+ if (backup -> status != BACKUP_STATUS_OK )
291
+ continue ;
292
+ else
293
+ {
294
+ char * backup_id ,
295
+ * corrupted_backup_id ;
294
296
295
- backup -> status = BACKUP_STATUS_ORPHAN ;
296
- pgBackupWriteBackupControlFile (backup );
297
+ backup -> status = BACKUP_STATUS_ORPHAN ;
298
+ pgBackupWriteBackupControlFile (backup );
297
299
298
- backup_id = base36enc_dup (backup -> start_time );
299
- corrupted_backup_id = base36enc_dup (corrupted_backup -> start_time );
300
+ backup_id = base36enc_dup (backup -> start_time );
301
+ corrupted_backup_id = base36enc_dup (corrupted_backup -> start_time );
300
302
301
- elog (WARNING , "Backup %s is orphaned because his parent %s is corrupted" ,
302
- backup_id , corrupted_backup_id );
303
+ elog (WARNING , "Backup %s is orphaned because his parent %s is corrupted" ,
304
+ backup_id , corrupted_backup_id );
303
305
304
- free (backup_id );
305
- free (corrupted_backup_id );
306
+ free (backup_id );
307
+ free (corrupted_backup_id );
308
+ }
306
309
}
307
310
}
308
311
}
@@ -1001,7 +1004,8 @@ parseRecoveryTargetOptions(const char *target_time,
1001
1004
TimeLineID target_tli ,
1002
1005
bool target_immediate ,
1003
1006
const char * target_name ,
1004
- const char * target_action )
1007
+ const char * target_action ,
1008
+ bool restore_no_validate )
1005
1009
{
1006
1010
time_t dummy_time ;
1007
1011
TransactionId dummy_xid ;
@@ -1026,6 +1030,7 @@ parseRecoveryTargetOptions(const char *target_time,
1026
1030
rt -> recovery_target_immediate = false;
1027
1031
rt -> recovery_target_name = NULL ;
1028
1032
rt -> recovery_target_action = NULL ;
1033
+ rt -> restore_no_validate = false;
1029
1034
1030
1035
/* parse given options */
1031
1036
if (target_time )
@@ -1072,6 +1077,12 @@ parseRecoveryTargetOptions(const char *target_time,
1072
1077
rt -> recovery_target_immediate = target_immediate ;
1073
1078
}
1074
1079
1080
+ if (restore_no_validate )
1081
+ {
1082
+ recovery_target_specified ++ ;
1083
+ rt -> restore_no_validate = restore_no_validate ;
1084
+ }
1085
+
1075
1086
if (target_name )
1076
1087
{
1077
1088
recovery_target_specified ++ ;
0 commit comments