PowerShell script exchange
Post Reply
knielsen
Novice
Posts: 4
Liked: never
Joined: Sep 27, 2014 8:37 pm
Full Name: Kim Nielsen
Contact:

Getting backup size per VM

Post by knielsen »

Hi,

I have been playing with the powershell API and I can get most of the info that I'm looking for. But I really want the size of every VM with a single backup job.

Can anyone help me in order to find that info ?

/Kim
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting backup size per VM

Post by veremin »

Hi Kim,

Are you willing to get information about VM processed size or about the size that particular VM occupies inside a backup file?

Thanks.
knielsen
Novice
Posts: 4
Liked: never
Joined: Sep 27, 2014 8:37 pm
Full Name: Kim Nielsen
Contact:

Re: Getting backup size per VM

Post by knielsen »

Hi,

Well both would be nice. But it seems that its not possible to see how big a backup is for one specific VM. But if I could just get the transfered numbers that is reported within the gui that would also be fine

/Kim
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting backup size per VM

Post by veremin »

You're right, it's not possible to get information on what amount of space is occupied by certain VM in the given backup file.

As to information regarding read/transferred/backup size data, please check this topic.

Thanks.
knielsen
Novice
Posts: 4
Liked: never
Joined: Sep 27, 2014 8:37 pm
Full Name: Kim Nielsen
Contact:

Re: Getting backup size per VM

Post by knielsen »

Thanks but its still per job and not VM .. no way to get the transfered per vm then ? its ok that its not possible via the API but hen via the SQL ?

/Kim
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting backup size per VM

Post by veremin »

Right, these metrics exist on job level. Thanks.
knielsen
Novice
Posts: 4
Liked: never
Joined: Sep 27, 2014 8:37 pm
Full Name: Kim Nielsen
Contact:

Re: Getting backup size per VM

Post by knielsen »

Hi,

I did the job now but the sizes are all wrong:

Code: Select all

asnp VeeamPSSnapin

$DebugPreference = "Continue"

$jobs = Get-VBRJob

$resultlist= @{}
foreach ($job in $jobs) {

    $vbrsessions = Get-VBRBackupSession -Name $job.Name | Where-Object {$_.JobType -eq "Backup"}

    $numsessions = 0
    foreach ($session in $vbrsessions) {

        $tasks = Get-VBRTaskSession -Session $session
        $taskalgorithm = $tasks.Info.WorkDetails.TaskAlgorithm

        "Task:" + $taskalgorithm
        

        [Int]$numvms = $session.Progress.TotalObjects
        [Int]$count = 0


        while ($count -lt $numvms) {
            $vmtask = $session.GetTaskSessions()[$count]

            write-debug($vmtask.info.progress|Format-Table|Out-String);

            "Total objects:" + $vmtask.info.progress.TotalObjects
         
            if (!$resultlist.ContainsKey($vmtask.Name)) {
                $resultlist[$vmtask.Name] = 0
            }
            
            $resultlist[$vmtask.Name] += $vmtask.Progress.TransferedSize
            

            $count++
        }

        "Number of tasks in job: " + $count
        $numsessions++        
    }

    "Number of sessions in job: " + $numsessions

    
    foreach ($h in $resultlist.GetEnumerator()) {
        "VM:" + $($h.Key) + " -- " + "{0:N2}" -f ($h.Value / 1MB) + " MB"
    }

  
    $jobs = (Get-VBRBackup -Name $jobname.JobName).GetStorages() | Select-Object -Property `
    @{N="Name";E={$_.FileName}},`
    @{N="Date";E={$_.CreationTime}},`
    @{N="DataSize";E={$_.Stats.DataSize}},`
    @{N="BackupSize";E={$_.Stats.BackupSize}},`
    @{N="De-dupe Ratio";E={$_.Stats.DedupRatio}},`
    @{N="Compress Ratio";E={$_.Stats.CompressRatio}} 

    $size = 0
    foreach ($job in $jobs.GetEnumerator()) {
        $size += $job.BackupSize
    }

    "Job: " + $jobname.JobName + " -- " + "{0:N2}" -f ($size / 1MB) + " MB"

    $startFolder = "Y:\" + $jobname.JobName

    $colItems = (Get-ChildItem $startFolder | Measure-Object -property length -sum)
    "Disk: " + "$startFolder -- " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB"

    $colItems = (Get-ChildItem $startFolder -recurse | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object)
    foreach ($i in $colItems) {
        $subFolderItems = (Get-ChildItem $i.FullName | Measure-Object -property length -sum)
        $i.FullName + " --- " + "{0:N2}" -f ($subFolderItems.sum / 1MB) + " MB"
    }

    exit 0
}
The output gives:

Total objects:12
Number of tasks in job: 1
Number of sessions in job: 43
VM:MYHOST -- 3,089,879.44 MB
Job: Backup Job02 Exch01 -- 14,510,121.52 MB
Disk: Y:\Backup Job02 Exch01 -- 14,510,121.70 MB

So the job and disksize are almost the same but when counting all ReadSize in every session I only get 3TB for a 3.7TB machine and its no where neer the jobsize. Can anyone maybe help out ?

/Kim
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Getting backup size per VM

Post by tsightler »

This doesn't really answer your question, but the amount of data transferred will not always correlate to the amount of data written as there are a lot of other factors that can lead to these values being different. The amount transferred represents the amount of data sent between our source and target data mover, but since the target data mover is responsible for things like job level dedupe, transforms, and other operations that can significantly impact the size of the backup itself, these factors are not represented by the read and transferred numbers. In small controlled cases they will likely appear to be very similar, but this is just a warning that in the "real world" trying to correlate the amount of data transferred to size of backup can be an exercise in futility.

Regarding the code, there are a few things that aren't clear to me that might be causing inaccurate results, for example $jobs is defined at the top of the script and used for the outer loop, but then $jobs is redefined within the loop down where Get-VBRBackup is called . Also, Get-VBRBackup is called using the Name parameter $jobname.JobName, but I don't see anywhere in the code where $jobname is previously defined, so the results are unpredictable at that point.
andresbarcenas
Novice
Posts: 5
Liked: never
Joined: Nov 10, 2014 3:39 pm
Full Name: Andres Barcenas
Contact:

Re: Getting backup size per VM

Post by andresbarcenas »

Is this something that is now available on Veeam V8? I need to be able to generate a report per Job per VM to show me how much storage including all restore points is currently utilized. By having this data, I can potentially start charging customers for backups overages.
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Getting backup size per VM

Post by Vitaliy S. »

Hi Andres, it doesn't matter whether it is version 7 or 8, consumed space within the backup file for each VM cannot be retrieved, since common blocks are shared among multiple VMs due to deduplication. Hope this makes sense!
tntteam
Enthusiast
Posts: 68
Liked: 5 times
Joined: Aug 28, 2015 12:40 pm
Full Name: tntteam
Contact:

Re: Getting backup size per VM

Post by tntteam »

Hi,

I'm digging this old thread but I can't find other valuable infos on the net...

I understand it is not possible to get how much space a specific VM takes in one job session.

Is it possible to extract how much data was read during session for a specific VM via powershell ?

I'm looking for this specific data : Image

Thanks for help !
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting backup size per VM

Post by veremin »

I understand it is not possible to get how much space a specific VM takes in one job session.
Should be possible, as long as you use per-VM backup chain.
Is it possible to extract how much data was read during session for a specific VM via powershell ?
This information is present in task session log, so, parse it to get whatever data you want to.
paul_parkes
Lurker
Posts: 2
Liked: 3 times
Joined: May 11, 2012 10:54 am
Full Name: Paul Parkes
Contact:

Re: Getting backup size per VM

Post by paul_parkes » 2 people like this post

The following code snippet should give you the per VM details for the last backup
Note, Progress.StartTimeLocal & Progress.StopTimeLocal are used in 9.5U3 prior to that use Progress.StartTime & Progress.StopTime

Code: Select all

# Load in the Veeam snapins
asnp VeeamP*

# Get a list of the scheduled jobs
$Jobs = Get-VBRJob | ?{$_.IsScheduleEnabled -eq "True"} | Sort Name

# Now create the VM report
ForEach ($Job in $Jobs) {
   $VMReport += Get-VBRTaskSession $Job.FindLastSession() | Select-Object Name ,JobName ,Status,@{Name="StartTime"; Expression = {$_.Progress.StartTimeLocal}},@{Name="StopTime"; Expression = {$_.Progress.StopTimeLocal}},@{Name="Duration"; Expression = {'{0:00}:{1:00}:{2:00}' -f $_.Progress.Duration.Hours, $_.Progress.Duration.Minutes, $_.Progress.Duration.Seconds}},@{Name="SizeGB"; Expression = {[math]::Round(($_.Progress.ProcessedSize/1GB),3)}},@{Name="UsedGB"; Expression = {[math]::Round(($_.Progress.ProcessedUsedSize/1GB),3)}},@{Name="ReadGB"; Expression = {[math]::Round(($_.Progress.ReadSize/1GB),3)}},@{Name="TransferedGB"; Expression = {[math]::Round(($_.Progress.TransferedSize/1GB),3)}}, @{N="Busy";E={($_.Logger.GetLog().updatedrecords.title | where {$_ -like "Busy*"}) -replace 'Busy: Source', 'Src' -replace 'Network', 'Net' -Replace 'Target', 'Tar' -Replace 'Proxy', 'Prx'}}, @{N="Used Proxy";E={($_.Logger.GetLog().updatedrecords.title | where {$_ -like "Using backup proxy*"}) -replace 'Using backup proxy ','' -replace 'for disk Hard','-'}}
   }
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests