I am new to restoring via Powershell, but have a new requirement to automate a number of SQL database restores for mirroring servers and smoke testing.
I have got the powershell working but I can't seem to recover the most recent backup available.The backup seems to recover the oldest (or first) sql backup available.
Does any one have experience , or know the command to restore the most recent SQL database available? I have tried setting the -TOPOINTINTIME with a variable but I am not able to get it to recover then (it fails)
My powershell as follows:
Code: Select all
Add-PSSnapin veeampssnapin
$restoreBacus = Get-VBRApplicationRestorePoint -SQL -Name "SQLDBVM08"
$locationBacus = Get-VBRSqlDatabase -ApplicationRestorePoint $restoreBacus[0] -Name "BACUS_PROD"
$setcreds = Add-VBRCredentials -user "UTK\UTK.SQLADMIN" -password "apasswordyes1!"
$guestcreds = Set-VBRCredentials -Credential $setcreds
Get-VBRSQLDatabaseRestoreInterval -Database $locationAbacus
Start-VBRSQLDatabaseRestore -Database $locationBacus -Servername "GPE-Jerex" -DatabaseName "BACUS_RESTORE" -GuestCredentials $setcreds -Force