PowerShell script exchange
Post Reply
sandsturm
Veteran
Posts: 317
Liked: 32 times
Joined: Mar 23, 2015 8:30 am
Location: Switzerland
Contact:

add new Azure blob storage account to existing backupjob with powershell

Post by sandsturm »

Hi

I want to add new Azure blob storage accounts to an existing backupjob in VBR via powershell. I try something like:

Code: Select all

$srv = Get-VBRUnstructuredServer -name "StorageAccountName"
$object = New-VBRObjectStorageBackupJobObject -Server $srv 
$job =  Get-VBRUnstructuredBackupJob -name "BKP_Job_01"
Set-VBRObjectStorageBackupJob -job $job -BackupObject $object -name "StorageAccountName"
The problem is, that Set-VBRObjectStorageBackupJob does not only add a new object to already existing objects. It "sets" the new object and therefore removes the already existing objects from the job and that is not what I want :-)
Is there a way to "add" additional objects (Azure blob storage accounts in my case) to an existing Unstructured Data object job via powershell?

thx,
sandsturm
david.domask
Veeam Software
Posts: 2727
Liked: 629 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: add new Azure blob storage account to existing backupjob with powershell

Post by david.domask » 1 person likes this post

Hi sandsturm,

Yes, it's a little unclear, but you can use the following process to update the Job Objects.

Code: Select all

$allObject = @()
$targetJob = Get-VBRUnstructuredBackupJob -Name "Name of job to add objects to"
$srv = Get-VBRUnstructuredServer -name "StorageAccountName"
$newObject = New-VBRObjectStorageBackupJobObject -Server $srv 
$originalObjects = $targetJob.BackupObject
$allObject += $originalObjects
$allObject += $newObject
Set-VBRObjectStorageBackupJob -Job $targetJob -BackupObject $allObject
Basically we take the existing objects, create an empty array $allObject and add both the new object and the original objects and add them to the empty array.

Then pass $allObject to -BackupObject parameter.

I will ask the tech writers to please add an example for this on the Set-VBRObjectStorageBackupJob page.
David Domask | Product Management: Principal Analyst
sandsturm
Veteran
Posts: 317
Liked: 32 times
Joined: Mar 23, 2015 8:30 am
Location: Switzerland
Contact:

Re: add new Azure blob storage account to existing backupjob with powershell

Post by sandsturm »

Hi David

Thanks a lot, this works great. Just one more question: Objects added in above mentioned way to an existing job do have an empty name, if I view the job details in VBR console. Is there a way to add the name as well?

btw, you have a small typo in above line "$originalObjects = $targetJob.BackupObjects" --> it's just .BackupObject without an ending "s". Maybe you can correct that, if someone else wants to use it as well.

thx,
sandsturm
david.domask
Veeam Software
Posts: 2727
Liked: 629 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: add new Azure blob storage account to existing backupjob with powershell

Post by david.domask »

Ahh, thanks for pointing out the typo, corrected it.

When you mention it has an empty name, can you maybe show a screenshot? I didn't see any such thing when I tried it, but maybe I was looking in wrong spot.
David Domask | Product Management: Principal Analyst
sandsturm
Veteran
Posts: 317
Liked: 32 times
Joined: Mar 23, 2015 8:30 am
Location: Switzerland
Contact:

Re: add new Azure blob storage account to existing backupjob with powershell

Post by sandsturm »

The first object "plistolsegenai01" was added via UI, the second without name was added via powershell:

https://snipboard.io/GdS9lZ.jpg
david.domask
Veeam Software
Posts: 2727
Liked: 629 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: add new Azure blob storage account to existing backupjob with powershell

Post by david.domask »

That's really strange -- I couldn't reproduce with an Azure container; can you do the following for me:

$job = Get-VBRUnstructuredBackupJob -Name "name of the affected job"
$bObject = $job.BackupObject
$bObject | Export-CliXml C:\temp\output.xml; start C:\temp

Share the output.xml file with me in a private message please.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 7 guests