PowerShell script exchange
Post Reply
tommls
Enthusiast
Posts: 37
Liked: never
Joined: Apr 28, 2015 7:52 pm
Full Name: Tom Lyczko
Contact:

PowerShell to gather backup sizes per server??

Post by tommls » Oct 13, 2016 1:18 pm

VMware has a cmdlet such that one can get a list of VMs' provisioned and used disk sizes.

Does Veeam have anything PowerShell that can do something similar??

I want to nightly get a list of the VMs backed up by Veeam with the size of the daily backup size per VM and the backup date (Get-Date).

I want a csv file output that I can put into Access and calculate daily changes.

Can anyone suggest a script for this?? Or at least the proper PowerShell code to output the daily backup size per VM??

Veeam support says they don't have anything to do this, which surprised me.

What I want is this: "You can see the VMs backed up by a job by going to the statistics of the job. To do this, right click on the job and select Statistics. In the left inside you will see a list of VMs. To see the size of the backup files, go to Backup & Replication --> Backups --> Disk, right click on your Job and select "Properties". The column Backup Size will show you the size of each backup file and the date when the file was created."

I want something to output this data rather than clicking all these backups every day...I can't imagine there's not a way via PowerShell, I'm just not knowledgeable enough to know or find it but once I know what it is I can work with it...This should be something standard in the application.

Thank you, Tom

tommls
Enthusiast
Posts: 37
Liked: never
Joined: Apr 28, 2015 7:52 pm
Full Name: Tom Lyczko
Contact:

how to get $Session.Info Backup Size PER VM PER JOB??

Post by tommls » Oct 13, 2016 2:14 pm

I found this in another forum thread, how can I make $Session.Info.BackupTotalSize become ALSO backup size PER VM??
Or anything similar??
I need a script that will look at each job and output the backup size per VM per job daily, after backups have finished.
What is the correct session variable to use??
Is there a list somewhere of session variables obtainable per VM per job per day??

Another way to put it: I need all the backup job properties per job per VM per day.

Thank you, Tom

asnp VeeamPSSnapin
$Job = Get-VBRJob -Name "Name of your job"
$Session = $Job.FindLastSession()
$Session.State
$Session.CreationTime
$Session.EndTime
$Session.Info.BackupTotalSize
$Session.BackupStats.CompressRatio
$Session.BackupStats.DataSize
$Session.BackupStats.DedupRatio

Thank you, Tom

tdewin
Veeam Software
Posts: 1356
Liked: 448 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: PowerShell to gather backup sizes per server??

Post by tdewin » Oct 14, 2016 1:38 pm

Check out Mimicscript : https://github.com/VeeamHub/powershell/ ... Report.ps1

Look for function calculate-vm and calculate-job. Those basically show you all the fields you are looking for and that are shown in the B&R reports (hence the name MimicReport) (perticiular how to get the "per vm session")

Final note, there is not field that says how much one VM represents inside a single restore point (it is also not something you can look up in the gui)

Andreas Neufert
Veeam Software
Posts: 3142
Liked: 545 times
Joined: May 04, 2011 8:36 am
Full Name: @AndyandtheVMs Veeam PM
Location: Germany
Contact:

Re: PowerShell to gather backup sizes per server??

Post by Andreas Neufert » Mar 29, 2018 1:59 pm

Wrote a small example for a customer for v9.5u3

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

Disconnect-VBRServer | out-null
connect-vbrserver -server dnsservername -user domain\username



Foreach ($JobObject in Get-VBRJob | ?{$_.JobType -eq "Backup"})
{
$LastSession = $JobObject.FindLastSession()
$JobObject.Name
$LastSession.endtime
$LastSession.Info.Progress.TotalUsedSize
$LastSession.Info.Progress.ReadSize
$LastSession.Info.Progress.TransferedSize
Write-Host "--------------------------------"
}

Andreas Neufert
Veeam Software
Posts: 3142
Liked: 545 times
Joined: May 04, 2011 8:36 am
Full Name: @AndyandtheVMs Veeam PM
Location: Germany
Contact:

Re: PowerShell to gather backup sizes per server??

Post by Andreas Neufert » Apr 15, 2018 10:54 pm 1 person likes this post

And again a new version that makes it more easy to look at the output (or import into Excel by copy and paste):

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

Disconnect-VBRServer | out-null
connect-vbrserver -server HQ-VBR1 -user amust\aneufert

$JobsOutput = @()


Foreach ($JobObject in Get-VBRJob | ?{$_.JobType -eq "Backup"})
{
$LastSession = $JobObject.FindLastSession()
$JobOutput = New-Object -TypeName PSObject
$JobOutput | Add-Member -Name "Jobname" -MemberType Noteproperty -Value $JobObject.Name
$JobOutput | Add-Member -Name "Endtime" -MemberType Noteproperty -Value $LastSession.endtime
$JobOutput | Add-Member -Name "TotalUsedSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.TotalUsedSize
$JobOutput | Add-Member -Name "ReadSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.ReadSize
$JobOutput | Add-Member -Name "TransferedSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.TransferedSize
$JobsOutput += $JobOutput

}
$JobsOutput | Out-GridView
Disconnect-VBRServer | out-null

tommls
Enthusiast
Posts: 37
Liked: never
Joined: Apr 28, 2015 7:52 pm
Full Name: Tom Lyczko
Contact:

Re: PowerShell to gather backup sizes per server??

Post by tommls » Apr 17, 2018 1:11 pm

Thank you!! :) :)

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests