diff --git a/pkg/dataprotection/restore/manager.go b/pkg/dataprotection/restore/manager.go index 9db86397a57..afbd4b4e386 100644 --- a/pkg/dataprotection/restore/manager.go +++ b/pkg/dataprotection/restore/manager.go @@ -204,7 +204,9 @@ func (r *RestoreManager) getBackupActionSetForContinuous(reqCtx intctrlutil.Requ if err != nil { return nil, err } - backupItems := append(fullBackupItems, incrementalBackupItems...) + backupItems := []dpv1alpha1.Backup{} + backupItems = append(backupItems, fullBackupItems...) + backupItems = append(backupItems, incrementalBackupItems...) // sort by completed time in descending order sort.Slice(backupItems, func(i, j int) bool { i, j = j, i diff --git a/pkg/dataprotection/restore/utils.go b/pkg/dataprotection/restore/utils.go index 8fa28390533..6ae2330564a 100644 --- a/pkg/dataprotection/restore/utils.go +++ b/pkg/dataprotection/restore/utils.go @@ -434,24 +434,27 @@ func ValidateParentBackupSet(parentBackupSet *BackupActionSet, backupSet *Backup parentBackup.Spec.BackupPolicyName, backup.Spec.BackupPolicyName) } // validate parent backup method - if parentBackupSet.ActionSet != nil && parentBackupSet.ActionSet.Spec.BackupType == dpv1alpha1.BackupTypeIncremental { + var parentBackupType dpv1alpha1.BackupType + if parentBackupSet.ActionSet != nil { + parentBackupType = parentBackupSet.ActionSet.Spec.BackupType + } + switch parentBackupType { + case dpv1alpha1.BackupTypeIncremental: if parentBackup.Spec.BackupMethod != backup.Spec.BackupMethod { return fmt.Errorf(`the parent incremental backup method "%s" is not the same with the child backup method "%s"`, parentBackup.Spec.BackupMethod, backup.Spec.BackupMethod) } - } else if parentBackupSet.ActionSet != nil && parentBackupSet.ActionSet.Spec.BackupType == dpv1alpha1.BackupTypeFull { + case dpv1alpha1.BackupTypeFull: if parentBackup.Spec.BackupMethod != backup.Status.BackupMethod.CompatibleMethod { return fmt.Errorf(`the parent full backup method "%s" is not compatible with the child backup method "%s"`, parentBackup.Spec.BackupMethod, backup.Spec.BackupMethod) } - } else { - return fmt.Errorf(`the parent backup "%s" is not incremental or full backup`, - parentBackup.Name) + default: + return fmt.Errorf(`the parent backup "%s" is not incremental or full backup`, parentBackup.Name) } // validate parent backup end time if !utils.CompareWithBackupStopTime(*parentBackup, *backup) { - return fmt.Errorf(`the parent backup "%s" is not before the child backup "%s"`, - parentBackup.Name, backup.Name) + return fmt.Errorf(`the parent backup "%s" is not before the child backup "%s"`, parentBackup.Name, backup.Name) } return nil }