Since one or two weeks one of my restore scripts isn't working any more. I haven't changed any thing since months in this script frame work.
Here a strongly shortened part, for easier understanding what I'm doing in script/module
Code: Select all
# Find Restore point with separate function
function Get-SQLBackup {
$rpStep1 = Get-VBRApplicationRestorePoint -SQL -Name $vmName -ErrorAction Stop
# ... filter by creation date
$myCreationDate = get-date -Date (get-date).AddDays($stepsBackward * -1) -Format "dd.MM.yyyy"
$rpSQL = ($rpStep1 | where { (Get-Date -Date $_.creationtime -Format "dd.MM.yyyy") -eq $myCreationDate } | select -First 1)
return $rpSQL
}
$rpSQL = Get-SQLBackup -vmName $vmName -stepsBackward $stepsBackward
$MyRestoreSession = Start-VESQLRestoreSession -RestorePoint $rpSQL.rpsql -ErrorAction Stop
$MyDB2Restore = Get-VESQLDatabase -Session $MyRestoreSession -Name $databasename -ErrorAction Stop | where { $_.InstanceName -eq $sourceInstance }
$MyDestinationDBFiles = Get-SQLServerDataPaths -ServerName $destinationServer -InstanceName $destinationInstance -Credential $destinationCredential # this function returns correct Data/Log Paths for destination instance
$paraRestoreVESQLDatabase = @{
Database = $MyDB2Restore
ServerName = $destinationServer # from script param
InstanceName = $destinationInstance # from script param
DatabaseName = $destinationDatabaseName # from script param
GuestCredentials = $destinationCredential # from script param fetched from password vault
SqlCredentials = $destinationCredential # from script param fetched from password vault
File = $MySourceDBFiles
TargetPath = $DBFilePaths
Force = $force
ErrorAction = 'Stop'
}
$resRestore = Restore-VESQLDatabase @paraRestoreVESQLDatabase
...
Code: Select all
Key : Database
Value : DWH_SOURCE_mtl - SQLINSTANCE1
Name : Database
Key : TargetPath
Value : {R:\MSSQL13.SQLINSTANCE1\MSSQL\DATA\DWH_SOURCE_mtl.mdf, S:\MSSQL13.SQLINSTANCE1\MSSQL\DATA\DWH_SOURCE_mtl_log.ldf}
Name : TargetPath
Key : ServerName
Value : <masked>
Name : ServerName
Key : InstanceName
Value : SQLINSTANCE1
Name : InstanceName
Key : DatabaseName
Value : DWH_SOURCE_mtl
Name : DatabaseName
Key : SqlCredentials
Value : System.Management.Automation.PSCredential
Name : SqlCredentials
Key : Force
Value : True
Name : Force
Key : GuestCredentials
Value : System.Management.Automation.PSCredential
Name : GuestCredentials
Key : ErrorAction
Value : Stop
Name : ErrorAction
Key : File
Value : {R:\MSSQL13.SQLINSTANCE1\MSSQL\DATA\DWH_SOURCE_mtl.mdf, S:\MSSQL13.SQLINSTANCE1\MSSQL\DATA\DWH_SOURCE_mtl_log.ldf}
Name : File
Are there any suggestions?