PowerShell script exchange
Post Reply
csmall
Enthusiast
Posts: 30
Liked: 2 times
Joined: Mar 20, 2018 1:19 pm
Full Name: Colin Small
Contact:

Get-VBRSQLDatabase Question

Post by csmall »

When running $Restorepoint = Get-VBRApplicationRestorepoint -SQL -Name "SERVERNAME" followed by a $Database = Get-VBRSQLDatabase -ApplicationRestorePoint $Restorepoint -Name "DATABASENAME"

I am confused by the results.

$Restorepoint shows the latest restorepoint (this date and time looks correct to me)
$Database shows me the the correct name of the database but the CreationTime is a date further back in the past than the data of the $Restorepoint.

It is almost a month different. Why?
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Get-VBRSQLDatabase Question

Post by jhoughes »

In your script, '$Restorepoint' should be giving you every SQL restore point from that particular server. You should identify a specific timestamp or ID of a specific restore point first.

Then you also need to run 'Start-VESQLRestoreSession' for that particular restore point before running Get-VBRSQLDatabase.

Example here:

Code: Select all


$All_SQL_RPs_ausveeambem = Get-VBRApplicationRestorePoint -SQL -Name 'ausveeambem'

$All_SQL_RPs_ausveeambem | Select-Object Name, CreationTime, Type, IsIndexed, IsCorrupted, Id | ft -AutoSize

Name        CreationTime           Type IsIndexed IsCorrupted Id
----        ------------           ---- --------- ----------- --
ausveeambem 3/7/2019 16:54:22      Full     False       False b8e1f4e4-62ef-46b7-94ad-932f4dabf9f7
ausveeambem 3/7/2019 20:53:24 Increment     False       False 25727001-1603-4836-87e6-926270174475
ausveeambem 3/8/2019 00:53:23 Increment     False       False 106c783d-2bfc-44e5-a5c8-4d53f87cf223
ausveeambem 3/8/2019 04:53:33 Increment     False       False 759b5c0e-dd6e-422e-b79f-951952712077


$Specific_RP =  Get-VBRApplicationRestorePoint -Id 106c783d-2bfc-44e5-a5c8-4d53f87cf223

$Specific_RP


IsExchange        : False
IsActiveDirectory : False
IsSharePoint      : False
IsSQL             : True
IsOracle          : False
CreationTime      : 3/8/2019 00:53:23
Type              : Increment
IsIndexed         : False
IsCorrupted       : False
Name              : ausveeambem
Id                : 106c783d-2bfc-44e5-a5c8-4d53f87cf223

$Restore_Session = Start-VESQLRestoreSession -RestorePoint $Specific_RP

$Restore_DB = Get-VESQLDatabase -Session $Restore_Session -Name 'VeeamBackupReporting'

$Restore_DB

Id                    : 1ec68eee-ae73-4110-a10d-dff4b9c6acb9
Name                  : VeeamBackupReporting
ServerName            : AUSVEEAMBEM
InstanceName          : VEEAMSQL2012
IsSystem              : False
IsReadonly            : False
IsBackedUp            : True
AvailabilityGroupName :
RecoveryModel         : Simple

Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
csmall
Enthusiast
Posts: 30
Liked: 2 times
Joined: Mar 20, 2018 1:19 pm
Full Name: Colin Small
Contact:

Re: Get-VBRSQLDatabase Question

Post by csmall »

Yes. I am identifying the restorepoint by using sort descending and select first 1 etc.. So $Restorepoint does return the correct restorepoint I am looking to use.

What I am confused by is the output of Get-VBRSQLDatabase -ApplicationRestorePoint $Restorepoint -Name "DATABASENAME" returning a creationtime a month earlier than the creationtime of the restorepoint itself. I was expecting the creationtime listed in the output to match the creationtime of the restorepoint itself.

Also,

Does Start-VESQLRestoreSession actually initiate any sort of actual database restore? I don't want to do that at this point in the script.

What used to do prior to any of the newer cmdlets was run $DatabaseToRestore = Get-VBRSQLDatabase -ApplicationRestorePoint $Restorepoint -Name "DATABASENAME"

followed by Start-VBRSQLDatabaseRestore -Database $DatabaseToRestore -ServerName TARGETRESTORESERVER -InstanceName " " -DatabaseName "DATABASENAME" -GuestCredentials $guestcred -SqlCredentials $sqlcred -Force

That worked fine.
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Get-VBRSQLDatabase Question

Post by jhoughes »

It doesn't begin a restore, but a restore session necessary to get the data contained within that restore point.

My guess would be that you are probably attaching to an old restore session, and that's why your results are out of sync.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
csmall
Enthusiast
Posts: 30
Liked: 2 times
Joined: Mar 20, 2018 1:19 pm
Full Name: Colin Small
Contact:

Re: Get-VBRSQLDatabase Question

Post by csmall »

I've never run a restore session for this. This is a fresh set of everything.

I'm starting to wonder if creationtime of the database inside the restorepoint is just the original date of the database (last month) and does not reflect the fact that it is an incremental from last night.

The restorepoint I am seeing the database information in does match up with last nights incremental.
csmall
Enthusiast
Posts: 30
Liked: 2 times
Joined: Mar 20, 2018 1:19 pm
Full Name: Colin Small
Contact:

Re: Get-VBRSQLDatabase Question

Post by csmall »

Is Start-VESQLRestoreSession the equivalent of running the "Restore Application Items", "Microsoft SQL Server Database Restore", Selecting a restore point and launching the SQL backup browser... without actually restoring any data until you tell it to?
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Get-VBRSQLDatabase Question

Post by jhoughes »

I believe so, but I'm not 100% certain.

I'd imagine that Vladimir could confirm once he sees this.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get-VBRSQLDatabase Question

Post by veremin »

Correct. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests