PowerShell script exchange
Post Reply
resruss
Service Provider
Posts: 56
Liked: 6 times
Joined: Apr 30, 2012 2:04 am
Contact:

Reporting on space consumed by each backup job

Post by resruss »

I've recently learned how great PowerShell can be (PowerCLI to report on storage and CPU / RAM for a folder) and looking to generate a report or script that can be used to show how much space is consumed by backups, per job
I understand this can't be done at a VM level, that's fine

I had a bit of a play with some partial scripts on here, but just can't see to stitch it together

Basically just after something to run and even just spit out into the PowerShell itself with output such as:
Job Name
Space Used

Anyone able to give me any pointers or show me where to start?
Even better, anyone got such a script they're willing to share?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Reporting on space consumed by each backup job

Post by veremin »

Is a target a Windows-based repository? If so, take a look at this script. Thanks.
tsightler
VP, Product Management
Posts: 6009
Liked: 2842 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Reporting on space consumed by each backup job

Post by tsightler » 1 person likes this post

If you have mulitple repositories that are a mix of Windows and Linux, calculating based on scanning the actual directory may be challenging since you have to work out paths, and potentially remote powershell/ssh, etc. I regularly use the following one-liner to get the size of the backup files on disk directly from the Veeam server. It's not quite 100% accurate because it doesn't account for metadata, but it's really close, with the exception of jobs that include periodic SQL log backups as those would need a little more code to grab the child job.

Code: Select all

((Get-VBRBackup -Name "<Backup_Name>").GetStorages().Stats.BackupSize | Measure-Object -Sum).Sum
This returns the size of the restore points on disk in bytes, which you can of course round however you wish if you prefer MB/GB/TB.
resruss
Service Provider
Posts: 56
Liked: 6 times
Joined: Apr 30, 2012 2:04 am
Contact:

Re: Reporting on space consumed by each backup job

Post by resruss »

tsightler wrote:If you have mulitple repositories that are a mix of Windows and Linux, calculating based on scanning the actual directory may be challenging since you have to work out paths, and potentially remote powershell/ssh, etc. I regularly use the following one-liner to get the size of the backup files on disk directly from the Veeam server. It's not quite 100% accurate because it doesn't account for metadata, but it's really close, with the exception of jobs that include periodic SQL log backups as those would need a little more code to grab the child job.

Code: Select all

((Get-VBRBackup -Name "<Backup_Name>").GetStorages().Stats.BackupSize | Measure-Object -Sum).Sum
This returns the size of the restore points on disk in bytes, which you can of course round however you wish if you prefer MB/GB/TB.
This is pretty much exactly what I'm after, thanks!

Quick question, I'm still a bit of a noob with PowerShell, how would I wrap that into a command or script to execute, looping through each job?
tsightler
VP, Product Management
Posts: 6009
Liked: 2842 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Reporting on space consumed by each backup job

Post by tsightler »

You could do something like:

Code: Select all

Get-VBRBackup | Select @{N="Job Name";E={$_.Name}}, @{N="Size (GB)";E={[math]::Round(($_.GetStorages().Stats.BackupSize | Measure-Object -Sum).Sum/1GB,1)}} | Format-Table -AutoSize
Which should give you output something like:

Code: Select all

Job Name    Size (GB)
--------    ---------
Job_1            13.3
Job_2           310.9
Job_3            16.5
Job_4             7.7
You could even export to a CSV file by simply replacing the Format-Table cmdlet with Export-Csv <path_to_file>.
cwidhelm
Lurker
Posts: 2
Liked: never
Joined: Feb 08, 2016 10:45 pm
Full Name: Chris Widhelm
Contact:

[MERGED] : PowerShell V8 Command for backup size

Post by cwidhelm »

I am needing to figure out the "backup size" with as much granularity as possible.

For example, Get-VBRRestorePoint gets me the granularity I want, however, ApproxSize is the Original Size and not the Backup Size.

Thanks
nielsengelen
Product Manager
Posts: 5619
Liked: 1177 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: PowerShell V8 Command for backup size

Post by nielsengelen »

Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Reporting on space consumed by each backup job

Post by veremin »

Hi, Chris,

Kindly, take a look at the script provided above and see whether it meets your expectations.

Thanks.
cwidhelm
Lurker
Posts: 2
Liked: never
Joined: Feb 08, 2016 10:45 pm
Full Name: Chris Widhelm
Contact:

Re: Reporting on space consumed by each backup job

Post by cwidhelm »

I suppose it will have to do. The GetStorages gets me the storage information for the entire restore point. I was hoping to have per VM statistics.

It would be great if there were object documentation in the PowerShell docs so we could see what methods and properties are available in the returned types.

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

Re: Reporting on space consumed by each backup job

Post by veremin »

Due to deduplication it's not possible to estimate how much space a particular VM consumes inside a backup file. Thanks.
bjdboyer
Service Provider
Posts: 60
Liked: 3 times
Joined: Nov 16, 2015 5:52 pm
Full Name: Bill Boyer
Contact:

[MERGED] Repository space per job

Post by bjdboyer »

I need a quick script that will take a backup job and tell me how much repository space is being used. We do billing based on how much "occupancy" each customer is using in the repository. Need like size-on-disk for each VM's points. Tried looping through the GetAllStorages() and looking at the stats.DataSize, but that total doesn't match what's in the /backup directory for that job. The VeeamOne billing report just doesn't cut it for our needs. We just need the total when we run the script. Month end.

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

Re: Reporting on space consumed by each backup job

Post by veremin »

Hi, Bill,

Can you tell me whether this one-liner meets your expectations?

Code: Select all

Get-VBRBackup | Select @{N="Job Name";E={$_.Name}}, @{N="Size (GB)";E={[math]::Round(($_.GetAllStorages().Stats.BackupSize | Measure-Object -Sum).Sum/1GB,1)}} | Format-Table -AutoSiz
Thanks.
fcocquyt16
Influencer
Posts: 13
Liked: 3 times
Joined: May 05, 2016 6:17 am
Full Name: Fletcher Cocquyt
Contact:

Re: Reporting on space consumed by each backup job

Post by fcocquyt16 » 1 person likes this post

Get-VBRBackup | Select @{N="Job Name";E={$_.Name}}, @{N="Size (GB)";E={[math]::Round(($_.GetAllStorages().Stats.BackupSize | Measure-Object -Sum).Sum/1GB,1)}} | Format-Table -AutoSize

works, but gives duplicate records for some jobs - eg

SIM 1304.8
SIM 1446.5

By comparing the actual du output space taken on the backup destination it looks like the correct space is the MAX of duplicate records
We have migrated jobs from old to new vcenters and it looks like the Veeam DB keeps the old records, resulting in the duplicates.

So in the case of the SIM job 1446.5 is the actual current value for space used by this job

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

Re: Reporting on space consumed by each backup job

Post by veremin »

It seems that there are duplicated entities in configuration db, as the result scripts shows backups with the same name twice. You might reach our support team and let them correct the database. Thanks!
Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 17 guests