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: 2863
Liked: 657 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: 2863
Liked: 657 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: 2863
Liked: 657 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
pouya
Influencer
Posts: 13
Liked: 1 time
Joined: Jun 18, 2018 12:00 am
Full Name: Phillip Ou Yang
Location: Sydney, Australia
Contact:

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

Post by pouya »

Hey guys, we seem to be having a similar issue. We are trying to script the entire process off adding ADLS into Veeam and then backing them up. We're able to add the objects without any issues but are having issues adding them into jobs.

We’ve had the issue that using the ‘New-VBRObjectStorageBackupJobObject’ cmdlet to add the server results in an error in the job

Our script to add these at the moment looks like:
$serv = Get-VBRUnstructuredServer -Name $name
$storageobject = New-VBRObjectStorageBackupJobObject -Server $serv
$repository = Get-VBRBackupRepository -Name $data_repo
$storageoptions = New-VBRStorageOptions -CompressionLevel Optimal -StorageOptimizationType LocalTarget
Add-VBRObjectStorageBackupJob -BackupObject $storageobject -Name $jobName -ShortTermBackupRepository $repository -StorageOptions $storageoptions -ErrorAction Stop

In the GUI, it looks like this, with the job failing:
Image

Just wondering how you guys were able to get around that?

Cheers!
david.domask
Veeam Software
Posts: 2863
Liked: 657 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 »

Hi pouya,

Regrettably was not able to make headway on this. In my environment (12.3.2), was not able to reproduce, but saw unusual behavior with sandsturm's environment I can't quite explain.

Can you re-upload your image? I checked the url directly but got an "image not found" from snipboard.
David Domask | Product Management: Principal Analyst
pouya
Influencer
Posts: 13
Liked: 1 time
Joined: Jun 18, 2018 12:00 am
Full Name: Phillip Ou Yang
Location: Sydney, Australia
Contact:

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

Post by pouya »

Hi David,

Yep seems like there was an issue with my link apologies! here it is-
Image
david.domask
Veeam Software
Posts: 2863
Liked: 657 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 »

Thanks for the fresh screenshot.

It's a bit strange, I cannot reproduce that particular error. I think your situation is a bit different than sandsturm's, so for yours please proceed with a Support Case. Be sure to include logs for the affected job.

Based on the Add-VBRObjectStorageBackupJob page, your script is following the example basically verbatim, so I'm not confident (yet) it's a script issue. I advise link my post here for support just in case they misinterpret your case as asking for scripting help, as for me looks like you followed the cmdlet example quite correctly.

Please share your case number once created. Thanks!
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests