@@ -243,66 +243,69 @@ do_restore_or_validate(time_t target_backup_id,
243243 if (is_restore )
244244 check_tablespace_mapping (dest_backup );
245245
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 )
253247 {
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+
271251 /*
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.
275253 */
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 -- )
283255 {
284256 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 ;
287263 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 -- )
291285 {
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 ;
294296
295- backup -> status = BACKUP_STATUS_ORPHAN ;
296- pgBackupWriteBackupControlFile (backup );
297+ backup -> status = BACKUP_STATUS_ORPHAN ;
298+ pgBackupWriteBackupControlFile (backup );
297299
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 );
300302
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 );
303305
304- free (backup_id );
305- free (corrupted_backup_id );
306+ free (backup_id );
307+ free (corrupted_backup_id );
308+ }
306309 }
307310 }
308311 }
@@ -1001,7 +1004,8 @@ parseRecoveryTargetOptions(const char *target_time,
10011004 TimeLineID target_tli ,
10021005 bool target_immediate ,
10031006 const char * target_name ,
1004- const char * target_action )
1007+ const char * target_action ,
1008+ bool restore_no_validate )
10051009{
10061010 time_t dummy_time ;
10071011 TransactionId dummy_xid ;
@@ -1026,6 +1030,7 @@ parseRecoveryTargetOptions(const char *target_time,
10261030 rt -> recovery_target_immediate = false;
10271031 rt -> recovery_target_name = NULL ;
10281032 rt -> recovery_target_action = NULL ;
1033+ rt -> restore_no_validate = false;
10291034
10301035 /* parse given options */
10311036 if (target_time )
@@ -1072,6 +1077,12 @@ parseRecoveryTargetOptions(const char *target_time,
10721077 rt -> recovery_target_immediate = target_immediate ;
10731078 }
10741079
1080+ if (restore_no_validate )
1081+ {
1082+ recovery_target_specified ++ ;
1083+ rt -> restore_no_validate = restore_no_validate ;
1084+ }
1085+
10751086 if (target_name )
10761087 {
10771088 recovery_target_specified ++ ;
0 commit comments