PowerShell script exchange
Post Reply
filipsmeets
Enthusiast
Posts: 37
Liked: 3 times
Joined: Jun 26, 2019 3:28 pm
Full Name: Filip Smeets
Contact:

Backup runtimes per VM's for trending

Post by filipsmeets »

Hi guys

I'm looking for a way to get the backup runtimes per VM so I can do some trending on the numbers.

This is what I got so far:

Code: Select all

$sessions = Get-VBRBackupSession |where{$_.Name -like ("Backup") -and $_.Name -notlike "*Retry*" -and $_.Result -eq "Success"}

$runtimesVMs = @()

foreach($session in $sessions)
{
    $taskSessions = $session | Get-VBRTaskSession

    foreach($task in $taskSessions)
        {
            $row = "" | Select Name,Date,Runtime
            $row.Name = $task.Name
            $row.Date = $task.Progress.StartTimeLocal.Date.ToShortDateString()
            $row.Runtime = [math]::Round((($task.Progress.StopTimeLocal - $task.Progress.StartTimeLocal).TotalHours),1)
            $runtimesVMs += $row
        }
}
$runtimesVMs
It's working but there are some weird negative numbers in the result.

Image
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Backup runtimes per VM's for trending

Post by jhoughes »

Rather than perform the math, you should just get the 'WorkDuration' sub-property for the 'WorkDetails' property of the task session.

For example, if your TaskSession is in the '$TaskSession' variable, do this:

Code: Select all

      try {
        $JobSessionDuration = $TaskSession.JobSess.SessionInfo.Progress.Duration.ToString()
      }
      catch {
        $JobSessionDuration = ''
      }
The try/catch block is to gather details only from any sessions with valid duration values (essentially, leave it blank for failed sessions).

If you also need the overall job session info, you can get that at the same time as well:

Code: Select all

      try {
        $TaskSessionDuration = $TaskSession.WorkDetails.WorkDuration.ToString()
      }
      catch {
        $TaskSessionDuration = ''
      }
I include both of these details in one of my Session report scripts which I will upload to VeeamHub soon, as it is getting covered during my upcoming VeeamON session.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
filipsmeets
Enthusiast
Posts: 37
Liked: 3 times
Joined: Jun 26, 2019 3:28 pm
Full Name: Filip Smeets
Contact:

Re: Backup runtimes per VM's for trending

Post by filipsmeets »

Thanks for the tip. Must of overlooked it.
$task.progress.duration seems to be the same as the one you mention.

I've also added a filter on the tasksessions to only take the ones with a taskAlgorithm "Increment". Not sure what the taskAlgorithm "Full" is but it showed a VM size of 0 so it wasn't useful.
Added some more data that could be of interest.

Code: Select all

$sites = import-csv
$runtimesVMs = @()
foreach($site in $sites)
{
    $sessions = Get-VBRBackupSession |where{$_.Name -like $site -and $_.Name -notlike "*Retry*" -and $_.Result -eq "Success"}

    foreach($session in $sessions)
    {
        $taskSession = $session | Get-VBRTaskSession |where{$_.Workdetails.TaskAlgorithm -eq "Increment"}

        foreach($t in $taskSession)
            {
                $row = "" | Select Job,VM,Date,TotalVMSize,TransferedSize,Runtime,avgSpeed
                $row.Job = $session.JobName
                $row.VM = $t.Name
                $row.Date = $t.Progress.StartTimeLocal.Date.ToShortDateString()
                $row.TotalVMSize = $t.Progress.TotalSize /1gb
                $row.TransferedSize = [math]::Round(($t.Progress.TransferedSize /1gb),2)
                $row.Runtime = [math]::Round(($t.Progress.Duration.TotalHours),1)
                $row.avgSpeed = [math]::Round(($t.Progress.AvgSpeed /1mb),2)
                $runtimesVMs += $row
            }
    }
}
$runtimesVMs | Sort VM,Date | Export-Csv
filipsmeets
Enthusiast
Posts: 37
Liked: 3 times
Joined: Jun 26, 2019 3:28 pm
Full Name: Filip Smeets
Contact:

Re: Backup runtimes per VM's for trending

Post by filipsmeets »

Does somebody know if the transform operations like merging and so on are included in the runtimes I'm using in my report?
filipsmeets
Enthusiast
Posts: 37
Liked: 3 times
Joined: Jun 26, 2019 3:28 pm
Full Name: Filip Smeets
Contact:

Re: Backup runtimes per VM's for trending

Post by filipsmeets »

I would like to split up the runtimes in actual backup copy runtimes and transform operation runtimes. Is that possible?
filipsmeets
Enthusiast
Posts: 37
Liked: 3 times
Joined: Jun 26, 2019 3:28 pm
Full Name: Filip Smeets
Contact:

Re: Backup runtimes per VM's for trending

Post by filipsmeets » 2 people like this post

Figured this out myself.
You can compare the duration time of the session with the sum of the tasks in that session. The session duration time includes the merge operations.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Backup runtimes per VM's for trending

Post by oleg.feoktistov » 1 person likes this post

Hi @filipsmeets,

My apologies, I was actually in the middle of testing your question but been busy with numerous tasks also.
That's correct. Glad you could figure it out anyways.

Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests