Veeam PowerShell: Get Backup Job Storage Size
Veeam Backup & Replication has a pretty extensive PowerShell extension, added to the Veeam Backup & Replication Management server by default. You can do a lot of cool stuff with it, ranging from just getting information about backup jobs to configuring new backup jobs and restoring items.
One of the clouds that I helped get out of the fog machine, uses Veeam B&R as its backup solution. Works like a charm for multi tenant environment, using the Enterprise Manager. As the nature of the cloud is dynamic, which includes the billing, I had the pleasure of creating a link between the Veeam deployment and a billing system. This was based on the amount of storage used by the clients virtual machines.
While creating this script, I found a lot of examples of scripts reporting the status of backup jobs, but no proper examples on how to report the backup jobs storage size. So after figuring it out and completing the billing script, I decided to put the part about getting the job size on GitHub.
So here it is!
[Update 09-03-2016]
This script has been updated to support Veeam Backup & Replication version 9.
Gist:
Tags In
Related Posts
20 Comments
Leave a Reply Cancel reply
You must be logged in to post a comment.
I get this when trying to run the script.
Item has already been added. Key in dictionary: ‘AmountVMs’ Key being added: ‘AmountVMs’
Hi,
Check my comment to Christoph, this one seems related to that as well.
Hi,
This has also been fixed in a newer version: https://github.com/smitmartijn/public-powershell/blob/master/Veeam/veeamGetBackupJobSizes.ps1
Hi,
i’m trying your script, but have problem with line 24
$restorePoints = $job.GetStorages() | sort CreationTime -descending
My System dont know the Method “GetStorages”
Have a hint for me?
Hi Christoph,
It seems like Veeam B&R version 9 switched a few things around, one of them being the GetStorages() cmdlet. I’ve added a line to the script that it’s only tested for version 8 and will get around to updating it sooner or later. Also, PRs are welcome on GitHub. :-)
Works fine. Thx!
Hi,
The script has been updated to support Veeam B&R 9, check: https://github.com/smitmartijn/public-powershell/blob/master/Veeam/veeamGetBackupJobSizes.ps1
Would you please suggest how to modify this script to NOT add up the backup job sizes??
I think I need to work with the += code??
I want to report backup size per VM per day per job, export results to csv file for eventually comparing daily backup sizes and growth.
Thank you, Tom
Hi Tom,
You can modify the part inside “foreach($vmName in $vmList)” to get a per VM result, as that loops basically adds everything up together and goes for the total numbers. So if you output to either csv or output there, it’ll tell you the per VM numbers.
Following up on tom12010’s request, how do you export the full results to a csv file? I’ve tried adding a ” | export-csv backupsizes_$(get-date -format yyyyMMdd-HHmm).csv” in various places, but that either gives me an error, creates a blank .csv files, or doesn’t create any file at all.
Hi,
That’s probably because the job information isn’t being stored in the script above. It can be an easy fix though. You’ll need to create a global variable to store everything in:
put this at the top of the script, just before the function getBackupInfo()
$global:results = @()
Then inside the function, where the $newEntry variable is build, create an object variable to put into the global array:
$jobInfo = new-object PSObject
$jobInfo | add-member -membertype NoteProperty -name “Job” -Value $jobName
$jobInfo | add-member -membertype NoteProperty -name “VMs” -Value $VMs
..etc..
$global:results += $jobInfo
Then at the end (after calling getBackupInfo() do this:
$global:results | Export-CSV backupinfo.csv
Hope that helps!
That worked great, thanks so much for the help!
Hello Martijn,
I was wondering if you could help me explaining how to modify the part inside “foreach($vmName in $vmList)” to get a per VM result. My Powershell skills aren’t that good that I can find out by myself.
Thanks in advance.
Regards, Jeroen
Now that I look at it a little bit closer, that was a dumb statement. That foreach only lists the VM names it doesn’t contain the per VM data stats. There doesn’t seem to be a per VM data output possible with the current script. It doesn’t seem like it’s possible from looking at the documentation, but I did find something here: http://dewin.me/visualspaghetti/
Have a look at the “Backup specific properties” where he talks about getting the restorepoints, which are made per VM. There can be more restorepoints per VM, so you’d need to go through all restorepoints and add everything up for the same VMs.
Hope that helps!
Hi, first of all Thanks for the script. It works with veeam 9.5 sor far. But I was wondering about one thing:
Processing backup job: Job-Customer1
Total VMs: 1
Total Backup Size: 96,94
Total Data Size: 265,88
List of VMs: CUSTOMER01-FS01,
What is the difference between the Total Backup Size and Total Data Size? Imho the Data Size should be smaller, but the backup size greater. Could you explain this to me? The VM size is approx. 95 GB . So were does the Data Size come from: Thanks a lot! marco
Hi Marco,
Veeam defined a ‘Backup Size’ as the amount of storage a VM takes up, so the maximum size a single backup run can produce. The ‘Data Size’ is defined as the data that’s on disk on the Veeam library. That sizes depends on how you configure the backup job; how many copies you’re keeping, how many full backups, etc.
So the data size should be bigger than the backup size by definition (otherwise you don’t have a full backup).
Thanks. That helped me. For me the name was just misleading.
Another question: Is it possible instead of Creating an output with line breaks to export it as CSV? So that I could do some maths with the results. Thanks a lot
Have a look at the thread below (tom12010), it has examples.
Hello, I need to capture data for monthly basis. Can you help?
Sure, create a scheduled task: https://technet.microsoft.com/en-us/library/cc748993(v=ws.11).aspx