Start-VBRSQLDatabaseRestore question

PowerShell script exchange

Start-VBRSQLDatabaseRestore question

Veeam Logoby jluce » Wed Apr 06, 2016 4:42 pm

As a newbie in PowerShell I got assigned a task to come up with a script that allows Veeam to copy a SQL database to our test SQL servers for their use daily. The source SQL server
is utilizing transaction SQL log backup provided by Veeam. A question came up while attempting to restore a SQL database that is covered by this whether Veeam is restoring only the snapshot or the snapshot and rerunning the logs up to the point called for by the -ToPointTime. The script we are using is as follows:

Code: Select all
Add-PSSnapin -Name VeeamPSSnapIn
$restorepoint = Get-VBRApplicationRestorePoint -SQL -Name "ProBus SQL" | Select -Last  1
$ProductionDatabase = Get-VBRSQLDatabase -ApplicationRestorePoint $restorepoint[0] -Name "MANGA"
$guestcreds = Get-VBRCredentials -Name "domain\veeamsvc"
$sqlcreds = Get-VBRCredentials -Name "domain\veeamsvc"
$DateTime  = (get-date)
$DateTimeDesired = $DateTime.AddMinutes(-30)
$UDateTime = $DateTimeDesired.ToUniversalTime()
Start-VBRSQLDatabaseRestore -Database $ProductionDatabase -ServerName TESTSQLSVR -DatabaseName MANGA_DAILY_PROD -GuestCredentials $guestcreds -SqlCredentials $sqlcreds -ToPointInTime $UDateTime


The script seems to run however the variable $UDateTime is a UniversalTime which produces the output "Wednesday, April 6, 2016 3:18:35 PM" which we are not sure is being read correctly. Any ideas on this subject?

One additional question is when using PowerShell, where are the logs for the interaction being stored?
Thanks!
jluce
Enthusiast
 
Posts: 25
Liked: 3 times
Joined: Wed Jan 14, 2015 2:23 am
Full Name: John Luce

Re: Start-VBRSQLDatabaseRestore question

Veeam Logoby v.Eremin » Wed Apr 06, 2016 4:50 pm

Just out of curiosity - why are you using universal time? Aren't you living in timezone differing from UTC? Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRSQLDatabaseRestore question

Veeam Logoby jluce » Wed Apr 06, 2016 6:20 pm

Somewhere along the line we ran into the need for the Get-VBRDatabaseRestoreInterval which returns its output UTC. Since we are not using it we could save ourselves some effort.
jluce
Enthusiast
 
Posts: 25
Liked: 3 times
Joined: Wed Jan 14, 2015 2:23 am
Full Name: John Luce

Re: Start-VBRSQLDatabaseRestore question

Veeam Logoby v.Eremin » Fri Apr 08, 2016 9:53 am

Not sure whether I got your question, does or does not the provided script work for you? In the latter case what particular error you get? Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRSQLDatabaseRestore question

Veeam Logoby jluce » Thu Apr 14, 2016 7:16 pm

The script seems to work. Before we give it to our boss. We wanted to be sure that the script as indicated will give us the latest log back -30 minutes.
jluce
Enthusiast
 
Posts: 25
Liked: 3 times
Joined: Wed Jan 14, 2015 2:23 am
Full Name: John Luce

Re: Start-VBRSQLDatabaseRestore question

Veeam Logoby v.Eremin » Fri Apr 15, 2016 8:45 am

Everything appears to be scripted properly. The only line I'm not sure about is conversion to universal time.

Typically, UTC differs from your local time, meaning $UDateTime variable will represent your current time plus or minus several hours. So, I'm wondering how point in time recovery would behave in this case: will it revert db to past 30 minutes or it will revert db to past several hours + 30 minutes.

Thus, I'd recommend to backup the SQL machine and check the script on it afterwards to see whether the code works as expected.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests