PowerShell script exchange
Post Reply
acasanovanex
Influencer
Posts: 12
Liked: 1 time
Joined: Apr 20, 2012 8:33 am
Contact:

Emulate recalculate button with powershell

Post by acasanovanex » 1 person likes this post

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
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Emulate recalculate button with powershell

Post by Vitaliy S. »

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!
acasanovanex
Influencer
Posts: 12
Liked: 1 time
Joined: Apr 20, 2012 8:33 am
Contact:

Re: Emulate recalculate button with powershell

Post by acasanovanex »

Thanks for your answer Vitaly.
gogotop
Lurker
Posts: 2
Liked: never
Joined: Jul 23, 2012 5:14 pm
Full Name: George Rusak
Contact:

Re: Emulate recalculate button with powershell

Post by gogotop »

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!
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Emulate recalculate button with powershell

Post by Vitaliy S. »

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
tsightler
VP, Product Management
Posts: 6009
Liked: 2842 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Emulate recalculate button with powershell

Post by tsightler »

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.
juacosta
Novice
Posts: 6
Liked: never
Joined: May 05, 2013 2:00 pm
Full Name: Juan Ramon Acosta
Contact:

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

Post by juacosta »

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
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin »

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.
juacosta
Novice
Posts: 6
Liked: never
Joined: May 05, 2013 2:00 pm
Full Name: Juan Ramon Acosta
Contact:

Re: Emulate recalculate button with powershell

Post by juacosta »

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 ?
tsightler
VP, Product Management
Posts: 6009
Liked: 2842 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Emulate recalculate button with powershell

Post by tsightler »

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.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin »

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.
juacosta
Novice
Posts: 6
Liked: never
Joined: May 05, 2013 2:00 pm
Full Name: Juan Ramon Acosta
Contact:

Re: Emulate recalculate button with powershell

Post by juacosta »

Thanks a lot Vladimir
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin »

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

Thanks.
boatmn810
Novice
Posts: 9
Liked: never
Joined: Aug 28, 2015 8:12 pm
Full Name: Jared
Contact:

Re: Emulate recalculate button with powershell

Post by boatmn810 »

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...
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin »

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.
edirschedl
Enthusiast
Posts: 44
Liked: 4 times
Joined: Jul 21, 2016 12:29 pm
Full Name: Emanuel Dirschedl
Contact:

[MERGED] Get estimated total size in backup job config

Post by edirschedl »

Hello,

is it possible to get the estimated "Total size" value on the backup job wizard (under the "Recalculate"-button) per Powershell?
If yes, with which command?

I need this information for some costs billing / accounting actions. I don't want to use the real size, because I need such information before the first backup starts.


Thank you,

Emanuel
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin »

Check the thread your post has been merged into. Some useful examples are provided above. Thanks.
billcouper
Service Provider
Posts: 150
Liked: 30 times
Joined: Dec 18, 2017 8:58 am
Full Name: Bill Couper
Contact:

Re: Emulate recalculate button with powershell

Post by billcouper » 1 person likes this post

None of the above examples are useful, as everyone agrees that this is an impossible task using powershell.
According to this thread, the only way is to manually click the 'Recalculate' button in the GUI.

I too, would like a powershell method of doing this. Is there any change in v9.5 that provides the ability to do this simple task using powershell?
Manually clicking recalculate on dozens of jobs is mildly amusing, but only the first time.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin »

Is there any change in v9.5 that provides the ability to do this simple task using powershell?
Unfortunately, no changes in terms of recalculate cmdlet. Thanks.
evilaedmin
Expert
Posts: 176
Liked: 30 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:

Re: Emulate recalculate button with powershell

Post by evilaedmin »

Any updates re: Update 4?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin »

No, Update 4 does not have a cmdlet for that. Thanks!
evilaedmin
Expert
Posts: 176
Liked: 30 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:

Re: Emulate recalculate button with powershell

Post by evilaedmin »

Just curious, is this at all on the road map?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin »

It's tracked, yes, but it is not something we will implement in short-term future. Thanks!
MaximT
Lurker
Posts: 1
Liked: never
Joined: Jul 31, 2023 8:40 pm
Full Name: Maxim Tolmachev
Contact:

[MERGED] Feature request

Post by MaximT »

Hi,

Could you please add option to recalculate the total size of VMs to backup via PowerShell?
We have preconfigured jobs that are based on the VMware tags and created a script that checks the size of the jobs. If size is zero it disables the job so there wouldn't be any errors or warnings. When you tag a VM for job that's disabled, as it didn't have any VMs to backup, you need to edit the job via GUI and press recalculate button so it would update the size and script would re-enable the job.

The only information that I could find on the Internet is this forum with latest reply in 2019. powershell-f26/emulate-recalculate-butt ... 14178.html

I logged a Case #06201324 and was advised that at this stage there is no command to do this.

Thanks,
Max
HannesK
Product Manager
Posts: 14287
Liked: 2877 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Emulate recalculate button with powershell

Post by HannesK »

Hello,
and welcome to the forum.

I merged your feature request to the existing thread and we count your request +1 👍

Best regards,
Hannes
Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests