-
- Service Provider
- Posts: 477
- Liked: 119 times
- Joined: Apr 03, 2019 6:53 am
- Full Name: Karsten Meja
- Contact:
Backup size per vm
Hi,
is it possible to get the backup size per vm?
I allready have the per job sizes.
VBR is 11a; backup repository is set to per-vm chain.
Thank you in advance.
Karsten
is it possible to get the backup size per vm?
I allready have the per job sizes.
VBR is 11a; backup repository is set to per-vm chain.
Thank you in advance.
Karsten
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Backup size per vm
Hi Karsten,
If you want to get backup size per each vm contained in a backup, you need to obtain storages and their sizes.
Example:
If want to get backup size per every vm chain, the concept is the same, but you also need to do some simple calculations to present the sum of backup sizes for each unique backup object.
Example:
Thanks,
Oleg
If you want to get backup size per each vm contained in a backup, you need to obtain storages and their sizes.
Example:
Code: Select all
$backup = Get-VBRBackup -Name 'Backup Job 1'
$rps = Get-VBRRestorePoint -Backup $backup
$totalRps = @()
foreach ($rp in $rps) {
$storage = $rp.FindStorage()
$sizeRounded = [Math]::Round($storage.Stats.BackupSize/1GB, 2)
$totalRps += $rp | select Name, @{n='BackupSizeGB';e={$sizeRounded}}
}
$totalRps
Example:
Code: Select all
$backup = Get-VBRBackup -Name 'Backup Job 1'
$rps = Get-VBRRestorePoint -Backup $backup
$objects = $backup.GetObjects()
$objectChains = @()
foreach ($object in $objects) {
$objectRps = $rps | where {$_.ObjectId -eq $object.Id}
$backupSize = 0
foreach ($objectRp in $objectRps) {
$storage = $objectRp.FindStorage()
$sizeRounded = [Math]::Round($storage.Stats.BackupSize/1GB, 2)
$backupSize += $sizeRounded
}
$objectChains += $object | select DisplayName, @{n='BackupSizeGB';e={$backupSize}}
}
$objectChains
Oleg
-
- Service Provider
- Posts: 477
- Liked: 119 times
- Joined: Apr 03, 2019 6:53 am
- Full Name: Karsten Meja
- Contact:
Re: Backup size per vm
Hi Oleg,
thank you very much. Wow. That is exactly it.
Have a nice week.
thank you very much. Wow. That is exactly it.
Have a nice week.
-
- Veeam Legend
- Posts: 251
- Liked: 136 times
- Joined: Mar 28, 2019 2:01 pm
- Full Name: SP
- Contact:
Re: Backup size per vm
This works amazing.
Now, how would i do this for All jobs? instead of 'Backup Job 1' I'd love all the jobs to get checked.
I'm assuming run the whole script for each job in jobs or something, but i am not a powershell expert
Now, how would i do this for All jobs? instead of 'Backup Job 1' I'd love all the jobs to get checked.
I'm assuming run the whole script for each job in jobs or something, but i am not a powershell expert
-
- Veeam Software
- Posts: 2123
- Liked: 513 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Backup size per vm
Hi @vmtech123,
Few ways but laziest way is just get all Backups and then use a foreach loop and nest the above code into the loop. For example:
Notice a few things:
1. Move the array initialization for $objectChains outside of the loop, otherwise it will initialize a new array on every loop (and erase the old one )
2. For any point calling the CBackupObject ($backups in Oleg's original code), we rename it to the variable $b chosen for the loop
Few ways but laziest way is just get all Backups and then use a foreach loop and nest the above code into the loop. For example:
Code: Select all
$backups = Get-VBRBackup
$objectChains = @()
foreach($b in $backups){
$rps = Get-VBRRestorePoint -Backup $b
$objects = $b.GetObjects()
foreach ($object in $objects) {
$objectRps = $rps | where {$_.ObjectId -eq $object.Id}
$backupSize = 0
foreach ($objectRp in $objectRps) {
$storage = $objectRp.FindStorage()
$sizeRounded = [Math]::Round($storage.Stats.BackupSize/1GB, 2)
$backupSize += $sizeRounded
}
$objectChains += $object | select DisplayName, @{n='BackupSizeGB';e={$backupSize}}
}
}
$objectChains
1. Move the array initialization for $objectChains outside of the loop, otherwise it will initialize a new array on every loop (and erase the old one )
2. For any point calling the CBackupObject ($backups in Oleg's original code), we rename it to the variable $b chosen for the loop
David Domask | Product Management: Principal Analyst
-
- Veeam Legend
- Posts: 251
- Liked: 136 times
- Joined: Mar 28, 2019 2:01 pm
- Full Name: SP
- Contact:
Re: Backup size per vm
Thanks so much. I appreciate the help and the fact you explained WHY I think i was on the right track but this makes sense.. Awesome
-
- Veeam Software
- Posts: 2123
- Liked: 513 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Backup size per vm
Always welcome! Good luck with scripting
And I'm glad you like the explanations; they come from the pain I went through learning this stuff, so learn from my pain
And I'm glad you like the explanations; they come from the pain I went through learning this stuff, so learn from my pain
David Domask | Product Management: Principal Analyst
Who is online
Users browsing this forum: No registered users and 7 guests