PowerShell script exchange
Post Reply
Quackzilla
Lurker
Posts: 1
Liked: never
Joined: Aug 25, 2020 11:44 am
Contact:

Reporting progress of Start-VBRZip

Post by Quackzilla »

Hi All,

I'm trying to report back live progress of a VBRZip to a database. The VBRZip object has the BaseProgress attribute which has the value. I need to run using -RunAsync so I can perform the DB inserts while the backup progresses however this seems to stop BaseProgress from updating. It just stays at 0.

Am i missing something here? Is there another way to query for job progress? How would you go about doing a similar operation?

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

Re: Reporting progress of Start-VBRZip

Post by veremin »

I think you can assign result of cmdlet execution to a variable:

Code: Select all

$ZIPSession = Start-VBRZip...
And, then, check its progress, using Info.Progress parameter or something similar:

Code: Select all

$ZIPSession.Info.Progress
Unfortunately, I cannot VPN to my lab at the moment, so, cannot double check this.

Thanks!
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Reporting progress of Start-VBRZip

Post by oleg.feoktistov » 2 people like this post

Hi @Quackzilla and Welcome to the Forums,

Unlike in the UI, in Powershell progress is not displayed dynamically until API is called multiple times and progress bar is configured in a script. You would need a loop for that. The simplest way could be:

Code: Select all

$entity = Find-VBRViEntity -Name 'VmName' -VMsAndTemplates
$repo = Get-VBRBackupRepository -Name 'SOBR-01'
$zip = Start-VBRZip -BackupRepository $repo -Entity $entity -RunAsync

$x = 0
while ($x -ne 100) {
    $session = Get-VBRBackupSession | where {$_.Id -eq $zip.Id -and $_.State -eq 'Working'}
    Clear-Host
    Write-Host -NoNewline "$($session.BaseProgress)% complete"
    $x = $session.BaseProgress
    Start-Sleep -Seconds 10
} 

This script retrieves Zip session progress dynamically every 10 seconds in one line until it reaches 100% or session stops.

Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 3 guests