none
Powershell crash when restoring SQL database from incremantal backup source (not from full express..) RRS feed

  • Question

  • Hi,

    I have trouble to have a scripts able to restore a SQL database to a alternate instance using the last incremental backup available. This work properly with the last express backup but not with incremental.

    We can do it with GUI, how can we do it with powershell ?

    Any idea ?

    Rgds
    /Christian

    Code working properly using a full express backup as source (row 3):

    $ProtectionGroupSQLObj = Get-ProtectionGroup $DPMServer | Where-Object { $_.FriendlyName -eq $ProtectionGroupName}
    $DataSourceSQLObj = Get-DataSource -ProtectionGroup $ProtectionGroupSQLObj | Where-Object { $_.Name -eq $SQLDatabaseName -and $_.Instance -eq $SourceServerName}   
    $RecoveryPointsSQLObj = Get-Recoverypoint -DataSource $SQLDatabases | Where-Object { $_.HasFastRecoveryMarker -eq "Fast" -and $_.IsRecoverable -and $_.Location -eq "Disk"}  | Sort-Object BackupTime -Desc
    $RecoveryPointToRestore = $RecoveryPointsSQLObj
    $ROP = New-RecoveryOption -TargetServer $DestinationServerName -SQL -RecoveryLocation OriginalServerWithDBRename -RecoveryType Recover -AlternateDatabaseDetails $AlternativeDatabaseObj -RestoreSecurit
    $RestoreJob = Restore-DPMRecoverableItem -RecoverableItem $RecoveryPointToRestore -RecoveryOption $ROP -Verbose

    Same code causing Powershell to crash, 3 rows using last incremental backup:

    $ProtectionGroupSQLObj = Get-ProtectionGroup $DPMServer | Where-Object { $_.FriendlyName -eq $ProtectionGroupName}
    $DataSourceSQLObj = Get-DataSource -ProtectionGroup $ProtectionGroupSQLObj | Where-Object { $_.Name -eq $SQLDatabaseName -and $_.Instance -eq $SourceServerName}   
    $RecoveryPointsSQLObj = Get-Recoverypoint -DataSource $SQLDatabases | Where-Object { $_.IsRecoverable -and $_.Location -eq "Disk"}  | Sort-Object BackupTime -Desc
    $RecoveryPointToRestore = $RecoveryPointsSQLObj
    $ROP = New-RecoveryOption -TargetServer $DestinationServerName -SQL -RecoveryLocation OriginalServerWithDBRename -RecoveryType Recover -AlternateDatabaseDetails $AlternativeDatabaseObj -RestoreSecurit
    $RestoreJob = Restore-DPMRecoverableItem -RecoverableItem $RecoveryPointToRestore -RecoveryOption $ROP -Verbose



    Tuesday, April 4, 2017 12:01 PM