PowerShell script exchange
Post Reply
studog
Novice
Posts: 4
Liked: never
Joined: Oct 26, 2021 9:04 pm
Contact:

FindBackupsByQuotaIds responce non serializable

Post by studog »

From within Veeam 11a, when trying to use the following via PowerShell,

Code: Select all

[Veeam.Backup.DBManager.CDBManager]::Instance.Backups.FindBackupsByQuotaIds(guid[] quotaIds)
The results come back with the following error.

Code: Select all

PS C:\> [Veeam.Backup.DBManager.CDBManager]::Instance.Backups.FindBackupsByQuotaIds($orgQuotaId)

Exception calling "FindBackupsByQuotaIds" with "1" argument(s): "Type 
'System.Linq.Enumerable+WhereSelectEnumerableIterator`2[[System.Collections.Generic.KeyValuePair`2[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089],[System.Collections.Generic.LinkedList`1[[Veeam.Backup.Model.CBackupInfo, Veeam.Backup.Model, Version=11.0.0.0, Culture=neutral, 
PublicKeyToken=bfd684de2276783a]], System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089],[Veeam.Backup.Common.Grouping`2[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089],[Veeam.Backup.Model.CBackupInfo, Veeam.Backup.Model, Version=11.0.0.0, Culture=neutral, PublicKeyToken=bfd684de2276783a]], 
Veeam.Backup.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=bfd684de2276783a]]' in Assembly 'System.Core, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089' is not marked as serializable."
At line:1 char:1
+ [Veeam.Backup.DBManager.CDBManager]::Instance.Backups.FindBackupsByQu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SerializationException
The $orgQuotaID is built from,

Code: Select all

$orgQuotaId = ([Veeam.Backup.Core.CJobQuota]::FindByOrganization(Veeam.Backup.Model.CVcdOrganization org, guid repositoryId).Id)
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: FindBackupsByQuotaIds responce non serializable

Post by soncscy »

hey studog,

First, is there a reason VeeamOne Reports don't work for you for this?

> $orgQuotaId = ([Veeam.Backup.Core.CJobQuota]::FindByOrganization(Veeam.Backup.Model.CVcdOrganization org, guid repositoryId).Id)

This is your issue as I see it. Checking the method FindByOrganizatioon, it accepts a CVcdOrganziation object and a repo ID.

the way to call the id from a variable in Powershell should be

$($variable.property)

In your case, since it's invoked in a method, let's assume you have the Org saved as $org and the Repository saved as $repo:

[Veeam.Backup.Core.CJobQuota]::FindByOrganization($org, $($repo.id))

Notice the syntax with the parentheses? I get your example gets the ID from the CJobQuota object, but it should be an object or a List as I see it.

Try passing it with the above and calling $orgQuotaID as a list object instead.

But I'd strongly suggest avoid using the .NET reflections and see if the standard VeeamOne reports do the same you need. I think it's better for you in the long-run. I had no issue with the above methods in my lab. Such items are not supported anyways, so you're stuck with what we can offer here on the forums :D
studog
Novice
Posts: 4
Liked: never
Joined: Oct 26, 2021 9:04 pm
Contact:

Re: FindBackupsByQuotaIds responce non serializable

Post by studog »

Hello soncscy,

Thank you for the response. This call is being used in some automation we have and not just for reporting. So I cant use VeeamOne for this. The results are then passed along to another set of scripts. This, with minor changes, has been working fine since Veeam 9.5 and up until Veeam 11. It then broke when we upgraded our Dev environment to 11a.

Without going into to much detail, here is where I am.
We are using Veeam Backup in conjunction with VMWare vCLoud Director or VCD.

Code: Select all

$Organization = "VCD_Org_String"
$VCDHost = "VCD_Host_String"

$repo = Get-VBRBackupRepository -Name $Organization -ScaleOut 
$vcdOrgItem = Find-VBRvCloudEntity -Organization -Name $Organization
$vcd = Get-VBRServer -Name $VCDHost -Type VcdSystem
$siteRef = ($vcd.Info.Options | select-xml -XPath '/root/VcdConnectionOptions/LocalSiteUid').Node.InnerXml
$hostSiteUid = [Veeam.Backup.Model.CVcdRef]::Make($siteRef)

$vcdOrg = New-Object -TypeName Veeam.Backup.Model.CVcdOrganization `
        -ArgumentList $vcdOrgItem.VcdId, $hostSiteUid, $vcdOrgItem.VcdRef, $vcdOrgItem.Name

$orgQuotaId = ([Veeam.Backup.Core.CJobQuota]::FindByOrganization($vcdOrg, $repo.Id).Id)

[Veeam.Backup.DBManager.CDBManager]::Instance.Backups.FindBackupsByQuotaIds($orgQuotaId) 
I have tried your exsample of using ,

Code: Select all

$orgQuotaId = ([Veeam.Backup.Core.CJobQuota]::FindByOrganization($vcdOrg, $($repo.Id)))
and then,

Code: Select all

[Veeam.Backup.DBManager.CDBManager]::Instance.Backups.FindBackupsByQuotaIds($orgQuotaId.Id)
as well as,

Code: Select all

[Veeam.Backup.DBManager.CDBManager]::Instance.Backups.FindBackupsByQuotaIds($($orgQuotaId.Id))
and still I get the same exception as before.

On a side note, we had also run into an issue of Veeam adding an additional required Argument as pointed out and solution provided here.
restful-api-f30/cvcdorganization-signat ... 77333.html
studog
Novice
Posts: 4
Liked: never
Joined: Oct 26, 2021 9:04 pm
Contact:

Re: FindBackupsByQuotaIds responce non serializable

Post by studog »

I have opened a case with Veeam Support:
Case #05110824
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: FindBackupsByQuotaIds responce non serializable

Post by oleg.feoktistov » 1 person likes this post

@studog, I'm afraid the case won't be much of a help here since your script invokes low-level unsupported methods of DBManager instance. Apparently, the implementation of FindBackupsByQuotaIds() method changed, and it no longer serializes data by quota ids. Could reproduce the same in my lab. Did you try the method below instead? I know that it doesn't fetch the data by quota id filter, but could be a start:

Code: Select all

[Veeam.Backup.DBManager.CDBManager]::Instance.VcdMultiTenancy.FindOrganizationBackups($vcdOrg)
Thanks!
chris.arceneaux
VeeaMVP
Posts: 695
Liked: 374 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: FindBackupsByQuotaIds responce non serializable

Post by chris.arceneaux » 1 person likes this post

Adding to what Oleg mentioned, here's a script on VeeamHub demonstrating the proposed method in action:

https://github.com/VeeamHub/powershell/ ... e.ps1#L159
studog
Novice
Posts: 4
Liked: never
Joined: Oct 26, 2021 9:04 pm
Contact:

Re: FindBackupsByQuotaIds responce non serializable

Post by studog »

Oleg and Chris,
Thank you for the information and the examples. We are running some test now and if they pass I will come back and let you know.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests