Getting backup size per VM

PowerShell script exchange

Getting backup size per VM

Veeam Logoby knielsen » Sat Sep 27, 2014 8:40 pm

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
knielsen
Novice
 
Posts: 4
Liked: never
Joined: Sat Sep 27, 2014 8:37 pm
Full Name: Kim Nielsen

Re: Getting backup size per VM

Veeam Logoby v.Eremin » Mon Sep 29, 2014 7:36 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Getting backup size per VM

Veeam Logoby knielsen » Mon Sep 29, 2014 10:42 am

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
knielsen
Novice
 
Posts: 4
Liked: never
Joined: Sat Sep 27, 2014 8:37 pm
Full Name: Kim Nielsen

Re: Getting backup size per VM

Veeam Logoby v.Eremin » Mon Sep 29, 2014 10:47 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Getting backup size per VM

Veeam Logoby knielsen » Wed Oct 08, 2014 2:46 pm

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
knielsen
Novice
 
Posts: 4
Liked: never
Joined: Sat Sep 27, 2014 8:37 pm
Full Name: Kim Nielsen

Re: Getting backup size per VM

Veeam Logoby v.Eremin » Fri Oct 10, 2014 8:14 pm

Right, these metrics exist on job level. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Getting backup size per VM

Veeam Logoby knielsen » Wed Oct 22, 2014 11:13 am

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
knielsen
Novice
 
Posts: 4
Liked: never
Joined: Sat Sep 27, 2014 8:37 pm
Full Name: Kim Nielsen

Re: Getting backup size per VM

Veeam Logoby tsightler » Wed Oct 22, 2014 3:07 pm

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.
tsightler
Veeam Software
 
Posts: 4768
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Getting backup size per VM

Veeam Logoby andresbarcenas » Mon Nov 10, 2014 4:58 pm

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.
andresbarcenas
Novice
 
Posts: 5
Liked: never
Joined: Mon Nov 10, 2014 3:39 pm
Full Name: Andres Barcenas

Re: Getting backup size per VM

Veeam Logoby Vitaliy S. » Mon Nov 10, 2014 7:17 pm

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!
Vitaliy S.
Veeam Software
 
Posts: 19556
Liked: 1101 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests