Emulate recalculate button with powershell

PowerShell script exchange

Emulate recalculate button with powershell

Veeam Logoby acasanovanex » Fri Nov 09, 2012 10:22 am

Hello,

Is there a way to emulate the recalculate button functionality (when editing/creating a job) from a powershell script?

I've already explored the Veeam.Backup.Core.CBackupJob and Veeam.Backup.Core.CObjectInJob objects but I was unable to find a method to achieve such thing.

I know I can get the VM size from vCenter but I would rather do it through Veeam...

Thanks.
Ángel
acasanovanex
Service Provider
 
Posts: 12
Liked: never
Joined: Fri Apr 20, 2012 8:33 am

Re: Emulate recalculate button with powershell

Veeam Logoby Vitaliy S. » Fri Nov 09, 2012 11:31 am

Hi Angel,

Not sure it is possible to emulate recalculate button with Veeam PowerShell commands (at least I haven't found a quick way to do that), so I would suggest using VMware's PowerCLI to calculate source VM data size.

Thanks!
Vitaliy S.
Veeam Software
 
Posts: 19575
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Emulate recalculate button with powershell

Veeam Logoby acasanovanex » Sat Nov 10, 2012 2:16 pm

Thanks for your answer Vitaly.
acasanovanex
Service Provider
 
Posts: 12
Liked: never
Joined: Fri Apr 20, 2012 8:33 am

Re: Emulate recalculate button with powershell

Veeam Logoby gogotop » Fri Nov 30, 2012 5:38 pm

I've been looking for a way to do this. Does anyone have a way to generate the size of the backup job via script?

We mave multiple backup jobs pointing to a single VMware cluster that has hundreds of VMs on it. We do this to meet the recommended backup size limits for backup jobs as recommended by Veeam. We want to get this value via script so we can write a report displaying the size of all the VMs in the backup job. This is used to allocate new machines in vCenter to the smallest sized backup job and as a notification for us to create a new backup job if the size limites have been reached. In vCenter VMs are placed into Resource Pools which are containers that are targeted in Veeam backup jobs. This way only the action of placing the machine into a VMware container is required to make sure its getting backed up. But the report really should come from the Veeam APIs as that is what we are trying to measure against. I found the value in $vbrjob.Info.IncludedSize. But it seems not to even populate unless the "Recalculate" button is pressed in the GUI, a tediously long process with lots of jobs. It was be very nice to get this action to happen automatically or via script.

Thanks!
gogotop
Lurker
 
Posts: 2
Liked: never
Joined: Mon Jul 23, 2012 5:14 pm
Full Name: George Rusak

Re: Emulate recalculate button with powershell

Veeam Logoby Vitaliy S. » Fri Nov 30, 2012 7:28 pm

gogotop wrote:Does anyone have a way to generate the size of the backup job via script?

Try the PS code discussed in this thread to get the info you need > Powershell script to report daily backup sizes
Vitaliy S.
Veeam Software
 
Posts: 19575
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Emulate recalculate button with powershell

Veeam Logoby tsightler » Fri Nov 30, 2012 8:02 pm

I don't know any way to force the "recalculate" button so that $vbrjob.Info.IncludedSize is updated, however, you should be able to get the equivalent by adding up the size of each Job Object within the job, which you can get from $vbrjob.GetObjectsInJob(). This will return an array of each object in the job, which will have a size available in the ApproxSizeString variable (for container objects it's the estimated used size of all VMs in the container). Unfortunately this value is a string so you have to manipulate it a little bit and add the values of all objects together. Something like the following should work:

Code: Select all
$job = Get-VBRJob -Name "Test Job"
$jobsize = 0
$job.GetObjectsInJob() | ForEach-Object {$jobsize = $jobsize + [decimal]($_.ApproxSizeString -replace " GB$")}


EDIT: I just noticed that this value isn't always updated either, but there is a "TryGetApproxSize()" method that I would think would be used to update an objects size info. I need to see if I can figure that out.
tsightler
Veeam Software
 
Posts: 4775
Liked: 1740 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

[MERGED] : How to make wizard to show size of Resource Pool

Veeam Logoby juacosta » Mon May 06, 2013 12:52 pm

Hello everyone,

I am using power shell to create a backup job that specifies a VMWare Resource Pool instead of individual VMs. I noticed that when I specify the resource pool on the "Add-VBRViBackupJob" commandlet. The size of the resource pool is not shown on the column nor Total Size field on the "Virtual Machines" step of the wizard. However, if I press the "recalculate" button it pulls the correct size

Any tips how to achieve this thru the Veem backup PS
juacosta
Novice
 
Posts: 6
Liked: never
Joined: Sun May 05, 2013 2:00 pm
Full Name: Juan Ramon Acosta

Re: Emulate recalculate button with powershell

Veeam Logoby v.Eremin » Mon May 06, 2013 1:49 pm

To be honest, I can’t see any way of how this can be done using Veeam PowerShell Snap-in only. I can’t get it work neither by using ApproxSizeString nor by TryGetApproxSize() method (probably, some more qualified guy might correct me).

So, from my perspective, apart from pushing “recalculate” button this information can be only obtained from hypervisor directly via PowerCLI.

Hope this helps.
Thanks.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Emulate recalculate button with powershell

Veeam Logoby juacosta » Mon May 06, 2013 2:37 pm

Thanks everyone fro the quick answer. The script and post are very useful. One last question If I want the GUI to show the size after my Job is created is then the "Recalculate" push button the only option ?
juacosta
Novice
 
Posts: 6
Liked: never
Joined: Sun May 05, 2013 2:00 pm
Full Name: Juan Ramon Acosta

Re: Emulate recalculate button with powershell

Veeam Logoby tsightler » Mon May 06, 2013 2:46 pm

I've also been unable to get this to work with previous attempts so for now it looks like the button press is the only option.
tsightler
Veeam Software
 
Posts: 4775
Liked: 1740 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Emulate recalculate button with powershell

Veeam Logoby v.Eremin » Mon May 06, 2013 2:48 pm

One last question If I want the GUI to show the size after my Job is created is then the "Recalculate" push button the only option ?

Yep, it seems to be the only option.

Moreover, after having done it, you’ll be able to get the right size of the job objects even through PS, using the following example:

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your Job”
$Job.info.IncludedSize


Hope this helps.
Thanks.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Emulate recalculate button with powershell

Veeam Logoby juacosta » Tue May 07, 2013 7:30 pm

Thanks a lot Vladimir
juacosta
Novice
 
Posts: 6
Liked: never
Joined: Sun May 05, 2013 2:00 pm
Full Name: Juan Ramon Acosta

Re: Emulate recalculate button with powershell

Veeam Logoby v.Eremin » Wed May 08, 2013 8:11 am

Not a problem. Should any additional help be needed, let’s know.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Emulate recalculate button with powershell

Veeam Logoby boatmn810 » Fri Aug 28, 2015 8:15 pm

V - is this supposed to refresh the backup jobs ?

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your Job”
$Job.info.IncludedSize

I am using v8 ....2030 and it is not refreshing the backup jobs..
We are migrating from one vcenter server to a new one (changing versions as well.)
So refreshing the backup list would be a great thing to do...
boatmn810
Novice
 
Posts: 6
Liked: never
Joined: Fri Aug 28, 2015 8:12 pm
Full Name: Jared

Re: Emulate recalculate button with powershell

Veeam Logoby v.Eremin » Mon Aug 31, 2015 10:41 am

Nope, as mentioned above, the provided command takes size as is. So, manual "Recalculation" is still needed. Once you run it, the given command will show the proper value. Thanks.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests