PowerShell script exchange
Post Reply
OzzyOstadal
Novice
Posts: 5
Liked: never
Joined: Aug 17, 2016 12:54 pm
Full Name: Stefan Ostadal
Contact:

Get-VBRSQLDatabase returning multiple objects per database

Post by OzzyOstadal »

Hi,

I'm trying to create a PowerShell script to allow me to script a point-in-time recover of SQL databases. I'd like to use this to restore databases to our non-prod environments for software releases and testing.

When I retrieve a recovery point (Get-VBRRestorePoint) I get a single Object returned, but when I pass this onto Get-VBRSQLDatabase it's returning two objects for each database that exists across every instance included in the Restore Point.

The RestorePointId is the same, but the Id is different for each database name.

Anyone seen this before and does anyone know why there is two entries for each?

TIA,
Stefan
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get-VBRSQLDatabase returning multiple objects per databa

Post by veremin »

How many databases are present inside SQL VM? How many got backed up (job statistics)? And how many get return by Get-VBRSQLDatabase?

Check this script; might be also helpful.

Thanks.
OzzyOstadal
Novice
Posts: 5
Liked: never
Joined: Aug 17, 2016 12:54 pm
Full Name: Stefan Ostadal
Contact:

Re: Get-VBRSQLDatabase returning multiple objects per databa

Post by OzzyOstadal »

Hi,

This particular VM has 4 SQL instances, with a total of 135 databases (inc. system db's).
I ran some tests on a smaller VM, single SQL instance with 7 databases (4 system, 1 user and 2 SSRS databases) and two objects are being returned also when I pass the Restore Point Object.

I've also tried the code in that script and it too returns two objects using last nights incremental restore point.

This is the Restore Point object being returned

Code: Select all

Info                : Veeam.Backup.Model.COibInfo
Id                  : 49add59b-1bb4-42a1-b123-bf2ef679d4b7
LinkIdNullable      : b04c5034-bed7-454c-b64a-399aaae2177d
OriginalOibId       : 49add59b-1bb4-42a1-b123-bf2ef679d4b7
LinkId              : b04c5034-bed7-454c-b64a-399aaae2177d
CreationTime        : 19/02/2018 21:25:05
CreationTimeUtc     : 19/02/2018 21:25:05
Type                : Increment
Algorithm           : Increment
PointId             : 0d8eb787-9a8d-4e64-a9c1-2e9e2c7dd20c
ObjectId            : b4e7d1c5-5e97-43bc-ab0f-1e926f5e3c82
StorageId           : a6441d11-f60f-425d-a9af-a8114c0af9fb
InsideDir           : d5ae3893-a936-4a45-af20-5164d5c22314 (b4db52fd-76fb-4f72-bd21-b6a8e7ea8186)
IsCorrupted         : False
IsRecheckCorrupted  : False
IsLicensed          : True
CreationUsn         : 167577482
IsConsistent        : True
ApproxSize          : 141876527104
VmName              : **********
Name                : **********
State               : Nothing
EffectiveMemoryMb   : 16384
GuestInfo           : Veeam.Backup.Model.CGuestInfo
AuxData             : Veeam.Backup.Core.COibAuxDataHv
ParentId            : 00000000-0000-0000-0000-000000000000
ParentOriginalOibId : 00000000-0000-0000-0000-000000000000
DisplayName         : **********
HvAuxData           : Veeam.Backup.Core.COibAuxDataHv
HasIndex            : False
HasExchange         : False
HasVeeamArchiver    : False
HasSharePoint       : False
HasSql              : True
HasAd               : False
HasOracle           : False
Fqdn                : **********
BackupId            : 7e651304-3357-451e-92da-8ebf698dc072
LinkableType        : Oib
IsFull              : False
MountToFull         : True

When I pass this onto Get-VBRSQLDatabase, I get these two objects

Code: Select all

RestorePointId : 49add59b-1bb4-42a1-b123-bf2ef679d4b7
ServerName     : **********
InstanceName   : 
IsSystem       : False
IsReadonly     : False
CreationTime   : 18/05/2017 15:10:30
Name           : ****
Id             : 0914ff8a-77d0-418f-97d9-3044a5b8c45c

RestorePointId : 49add59b-1bb4-42a1-b123-bf2ef679d4b7
ServerName     : **********
InstanceName   : 
IsSystem       : False
IsReadonly     : False
CreationTime   : 18/05/2017 15:10:30
Name           : ****
Id             : 3d3bb839-8e1c-49e1-adec-49e108080d04
The ServerName and Name both match in each object for server and the database
OzzyOstadal
Novice
Posts: 5
Liked: never
Joined: Aug 17, 2016 12:54 pm
Full Name: Stefan Ostadal
Contact:

Re: Get-VBRSQLDatabase returning multiple objects per databa

Post by OzzyOstadal »

This is my test code

Code: Select all

$JobName = "**********"
$Instance = "**********"
$DB = "****"

$RestorePoint = Get-VBRRestorePoint -Backup $JobName | ? VmName -match "^$Instance" | Sort-Object -Property CreationTime -Descending | Select-Object -First 1
Get-VBRSQLDatabase -ApplicationRestorePoint $RestorePoint -Name $DB
OzzyOstadal
Novice
Posts: 5
Liked: never
Joined: Aug 17, 2016 12:54 pm
Full Name: Stefan Ostadal
Contact:

Re: Get-VBRSQLDatabase returning multiple objects per databa

Post by OzzyOstadal »

Just realised that the ID returned for the Get-VBRSQLDatabase is the GUID for the database. The instances I'm testing only have a single database with that name, so not sure why it has a different GUID in that restorepoint
OzzyOstadal
Novice
Posts: 5
Liked: never
Joined: Aug 17, 2016 12:54 pm
Full Name: Stefan Ostadal
Contact:

Re: Get-VBRSQLDatabase returning multiple objects per databa

Post by OzzyOstadal »

Still no idea why there are duplicate objects being returned.

Another server with a single user database is returning 3 objects. If I pass each Object to Get-VBRSQLDatabaseRestoreInterval or Start-VBRSQLDatabaseRestore only one of the objects work.

I'm using this code in my script and it appears to pick the correct database object with the restore points.

$DatabaseRestorePoint = Get-VBRSQLDatabase -ApplicationRestorePoint $ApplicationRestorePoint -Name $DatabaseName | Sort-Object -Property CreationTime -Descending | Select-Object -First 1

Time will tell
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get-VBRSQLDatabase returning multiple objects per databa

Post by veremin »

If you execute the same process via UI, will you get the similar result? My assumption is that for some reason db contains duplicated entities and those get returned by PS.

Might be worth logging a support case.

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests