PowerShell script exchange
Post Reply
GregorS
Veeam ProPartner
Posts: 55
Liked: 12 times
Joined: Apr 10, 2013 12:11 pm
Full Name: Gregor Smerke
Location: Ljubljana, SI - Slovenia
Contact:

How to Detach and then Import an Object Storage?

Post by GregorS »

Dear fellow scripters

(Still on VBR v11 :oops:) I need a PowerShell equivalent to:
1. Backup Infrastructure --> Backup Repositories --> S3 Object Storage (instance) --> Detach repository [command] (is it Unmount-VBRObjectStorageRepository?)
and then
2. Backup Infrastructure --> Backup Repositories --> S3 Object Storage (instance) --> Import Backup... [command] (not sure which cmdlet?)
Reference: Managing Object Storage Repositories.


Kind regards
Gregor
GregorS
Veeam ProPartner
Posts: 55
Liked: 12 times
Joined: Apr 10, 2013 12:11 pm
Full Name: Gregor Smerke
Location: Ljubljana, SI - Slovenia
Contact:

Re: How to Detach and then Import an Object Storage?

Post by GregorS » 1 person likes this post

Answering my own question :D:

Code: Select all

$ObjectStorageRepository = Get-VBRObjectStorageRepository -Name "A S3 Object Storage"
Unmount-VBRObjectStorageRepository -Repository $ObjectStorageRepository -Force
$EncryptionKey = Get-VBREncryptionKey -Description "An Encryption Password"
Mount-VBRObjectStorageRepository -Repository $ObjectStorageRepository -EncryptionKey $EncryptionKey
The last command returned a "Temporary helper SOBR for importing backups from object storage" which I did not save into a variable. Now I am figuring out how to programmatically determine when the Configuration Database Resynchronize task status will turn from Working to Success (in other works how to wait for completion). (?)
GregorS
Veeam ProPartner
Posts: 55
Liked: 12 times
Joined: Apr 10, 2013 12:11 pm
Full Name: Gregor Smerke
Location: Ljubljana, SI - Slovenia
Contact:

Re: How to Detach and then Import an Object Storage?

Post by GregorS »

Guys, how do I get a Configuration Database Resynchronize job (History --> System --> Configuration Database Resynchronize [instance])? I need to (programmatically) wait for it to finish (Status -ne "Working").
david.domask
Veeam Software
Posts: 2121
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to Detach and then Import an Object Storage?

Post by david.domask »

Hi @GregorS,

I'm not sure there's a supported method at this time for getting it. If you're willing to go into unsupported territory with .NET Reflection, you can use the following:

[Veeam.backup.Core.CBaseSession]::FindLastByJobType("102")

This just returns the most recent Configuration Database Resynchronize Task. If you're expecting to launch a bunch of these at once, you can use the GetRunning() method and then filter on JobType "102"
David Domask | Product Management: Principal Analyst
GregorS
Veeam ProPartner
Posts: 55
Liked: 12 times
Joined: Apr 10, 2013 12:11 pm
Full Name: Gregor Smerke
Location: Ljubljana, SI - Slovenia
Contact:

Re: How to Detach and then Import an Object Storage?

Post by GregorS »

Hmm... Error: Unable to find type [Veeam.Backup.Core.CBaseSession]. (?)
david.domask
Veeam Software
Posts: 2121
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to Detach and then Import an Object Storage?

Post by david.domask »

Hi!

DId you launch this from a Powershell console with the Veeam Powershell Module loaded? (You can do this automatically from Veeam from the Menu > Console > Powershell, or from any powershell with Veeam console installed by Import-Module Veeam.Backup.Powershell.

You will need to run _any_ normal cmdlet first, like Get-VBRLicenseAutoUpdateStatus
David Domask | Product Management: Principal Analyst
GregorS
Veeam ProPartner
Posts: 55
Liked: 12 times
Joined: Apr 10, 2013 12:11 pm
Full Name: Gregor Smerke
Location: Ljubljana, SI - Slovenia
Contact:

Re: How to Detach and then Import an Object Storage?

Post by GregorS »

You are right, the module has not been loaded yet. The object returned has a State property that I can use to wait until Stopped. Thanks!
david.domask
Veeam Software
Posts: 2121
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to Detach and then Import an Object Storage?

Post by david.domask »

Happy to help! And glad it was that simple :)
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests