PowerShell script exchange
Post Reply
oskargunn
Lurker
Posts: 1
Liked: never
Joined: Mar 12, 2018 1:44 pm
Full Name: Óskar Gunnarsson
Contact:

Powershell - Point In Time Restore of SQLServer database

Post by oskargunn »

Hi,

I wonder if someone could point me to the right direction concerning point-in-time restore of an SQLServer database.

Code: Select all

$ServerName = "<my restore machine>"    
$InstanceName = " " # If you have default instance, use " "
$DatabaseName = "DatabaseToRestore"
$DatabaseNameNew = "$($DatabaseName)_new"
$Restore_VM = "<Name of vm machine name>"

#OS and SQL Credentials, these must be stored in the credentials store in Veeam
$guestcreds = Get-VBRCredentials -Name  "domain\name" 
$sqlcreds = Get-VBRCredentials -Name "domain\name" 

#Adjust after the WHERE clause for the right date.
$Restore = Get-VBRApplicationRestorePoint -Name "<Name of vm machine name>" -SQL  | Where {$_.CreationTime.year -like "2018" -and $_.CreationTime.month -like "2" -and $_.CreationTime.day -like "24"}

$DBRestorePoint = Get-VBRSQLDatabase -ApplicationRestorePoint $Restore[0] -Name $DatabaseName
Get-VBRSQLDatabaseRestoreInterval -Database $DBRestorePoint

The "Get-VBRSQLDatabaseRestoreInterval -Database $DBRestorePoint" command returns:

FromUTC ToUTC
------- -----
24.2.2018 22:27:28 24.2.2018 22:27:28

Which is basically the point of the snapshot image.

Is there another method to retrieve am more broader timeframe. My goal is to automate restore through powershell scripts, preferably some point in time.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Powershell - Point In Time Restore of SQLServer database

Post by veremin »

Are you using SQL transaction log backup? If yes, isn't the provided restore the latest one by any chance? Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests