PowerShell script exchange
Post Reply
jnap
Enthusiast
Posts: 56
Liked: 4 times
Joined: Feb 11, 2020 4:54 pm
Contact:

Need stats for VBR NAS Backup Jobs/sessions/tasks

Post by jnap »

Hello,
We have a few nas backup jobs with 150/200 objects into.
We want to get some stats with powershell to generate a daily mail report, as we already do that for the vm backup jobs.
So, we tried to use those cmdlet:

get-vbrnasbackupsession
get-vbrnasbackuptasksession

But both are very slow to answer and it didn't give what you want..
Is there any .net methode to replace them?

We want to get :
- number of objects per job
- status of each nas backup object
- if failed, the error/warning message


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

Re: Need stats for VBR NAS Backup Jobs/sessions/tasks

Post by oleg.feoktistov »

Hi,

Can you, please, elaborate on "very slow" part? Do you have any cmdlet execution time to session count ratio stats?
Also, what do you mean by nas backup object in your case? A single share being backed up or every file/folder in it?

Thanks,
Oleg
jnap
Enthusiast
Posts: 56
Liked: 4 times
Joined: Feb 11, 2020 4:54 pm
Contact:

Re: Need stats for VBR NAS Backup Jobs/sessions/tasks

Post by jnap »

Hello,

Very slow is like 1hour to get stats from 4 jobs and more than 300 file shares (ie the job objects)
with this code:

Code: Select all

$ListNASJob= [Veeam.Backup.Core.CBackupJob]::GetAll() | Where-Object { $_.JobType -match "NASBackup" -and $_.info.IsScheduleEnabled -eq $true -and $_.Name -notmatch 'Copy'}

foreach($Name in $ListNasJob)
{
$NASJob = Get-VBRNASBackupJob -Name $ListNasJob.Name
foreach ($Path in $NASJob)
{
$NASPath = $NASJob.BackupObject.Path
$taskSessions = Get-VBRNASBackupTaskSession -Name "$NASPath" | where {$_.State -eq 'Stopped'-and $_.EndTime -ge (Get-Date).addhours(-24)}
}
}
oleg.feoktistov
Veeam Software
Posts: 2028
Liked: 675 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Need stats for VBR NAS Backup Jobs/sessions/tasks

Post by oleg.feoktistov »

Hi,

I don't see that Get-VBRNASBackupSession is used in your script, but I do see that you leverage CBackupJob.GetAll() method, which is for getting all backup jobs. It means that regardless of all the filtering cmdlets you pipe the output to, you will always wait for all the backup job records to be obtained first. Any particular reason you use it for?
If it is for the filters, you can just attach them to Get-VBRNASBackupJob with a slight fix and it should work faster:

Code: Select all

$NASJobs = Get-VBRNASBackupJob | where {$_.Name -notmatch 'Copy' -and $_.ScheduleEnabled -eq $true}
Thanks,
Oleg
jnap
Enthusiast
Posts: 56
Liked: 4 times
Joined: Feb 11, 2020 4:54 pm
Contact:

Re: Need stats for VBR NAS Backup Jobs/sessions/tasks

Post by jnap »

Hello,
We tried this :

Code: Select all

Get-VBRNASBackupJob | where {$_.Name -notmatch 'Copy' -and $_.ScheduleEnabled -eq $true}
but it takes a few minutes
and

Code: Select all

$ListNASJob= [Veeam.Backup.Core.CBackupJob]::GetAll() | Where-Object { $_.JobType -match "NASBackup" -and $_.info.IsScheduleEnabled -eq $true -and $_.Name -notmatch 'Copy'} 
takes a few seconds ... so...
oleg.feoktistov
Veeam Software
Posts: 2028
Liked: 675 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Need stats for VBR NAS Backup Jobs/sessions/tasks

Post by oleg.feoktistov » 1 person likes this post

Hi,

Even so, according to your script, I still don't get why you need to use Get-VBRNASBackupJob in every iteration of your loop after getting all NAS jobs with .NET method. Instead you could just query all NAS jobs with one supported cmdlet and then operate over each job in a loop:

Code: Select all

$ListNASJob= Get-VBRNASBackupJob  | where { $_.ScheduleEnabled -eq $false -and $_.Name -notmatch 'Copy'}

foreach($job in $ListNasJob) {
  $NASPath = $job.BackupObject.Path
  $taskSessions = Get-VBRNASBackupTaskSession -Name "$NASPath" | where {$_.State -eq 'Stopped'-and $_.EndTime -ge (Get-Date).addhours(-24)}
}
I tried both scripts in my lab and the example above worked at least twice as faster.

Besides, I still don't see how the script we are discussing is relevant to Get-VBRNASBackupSession performance. Adding this cmdlet to the code above does impact execution time, but it looks insignificant comparing to the approach you used (at least in my lab). Does the example I shared speed it up in your case?

Also, you stated that the nas cmdlets didn't give the info you wanted and listed the specifics you need to get. Are you looking for object count, status and error message metrics for each file/folder or nas share processed in a job?

Thanks,
Oleg
vguru1
Lurker
Posts: 1
Liked: never
Joined: Jun 15, 2023 4:19 am
Full Name: Jeffrey Weiss
Contact:

Re: Need stats for VBR NAS Backup Jobs/sessions/tasks

Post by vguru1 »

Oleg,

How can we modify your script to list Successful NAS Copy Jobs per Share as opposed to NAS Backup jobs?

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

Re: Need stats for VBR NAS Backup Jobs/sessions/tasks

Post by oleg.feoktistov »

With nas copy jobs it's a bit tricky, but you can reference share paths from nas backup jobs, which are parents to nas copies:

Code: Select all

$nasJobs = Get-VBRNASBackupJob
foreach ($nasJob in $nasJobs) {
    $nascopyJobs = Get-VBRNASBackupCopyJob -ParentJob $nasJob
    foreach ($nascopyJob in $nascopyJobs) {
         $NASPath = $nasJob.BackupObject.Path
        $taskSessions = Get-VBRNASBackupTaskSession -Name "$NASPath" | where {$_.State -eq 'Stopped'-and $_.Result -eq 'Success'}
        $taskSessions

    }
}
Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest