Analyze Veeam backup job selection with PowerShell

Analyze Veeam backup job selection with PowerShell

In this short post I show how to analyze Veeam backup job selection with PowerShell. I share two simple code snippets. The first will list all Veeam backup jobs with selected object types for VM backup. These can be Virtual Machines, Tags, Hosts and so on. Second part will show all jobs that use different object types. This can be very helpful to get an overview of backed up resource types.

Backup job object selection

The first code creates the array $result. This array contains all backup jobs, its selected objects and their types. Commands should be easy to understand.

$result = @()
foreach ($Job in (Get-VBRJob | Where-Object {$_.JobType -eq "backup"})) {
    foreach ($Obj in (Get-VBRJobObject -Job $Job | Where-Object {$_.Type -eq "Include"})) {
        $result += [pscustomobject]@{
                          JobName = $Job.Name;
                          Object = $Obj.Name;
                          Type = $Obj.TypeDisplayName}
    }
}

In my example I have a job with 4 different source types.

The output looks like this:

I just want to focus the attention to line 3. Here only job objects of type “Include” are selected. What does this mean? Objects of type “Include” are these objects that are listed in Virtual Machines of the backup job definition. This is important because when you exclude VMs or add them to Guest Processing explicitly, different types are used. You can see in the following screenshot.

Find jobs selected different object types

If you want to keep your jobs single-variety, a fast query is needed for monitoring respectively checking current configuration. This can easily done by PowerShell. With the $result-array from script before, you can run the following code.

$result | Select-Object JobName, Type | Group-Object JobName | foreach {
    if ((($_.group | Group-Object Type) | Measure-Object).count -gt 1) {Write-Host $_.Name}
}

As Output you will get the jobname for each backup job that uses more than one object type.

Notes

Leave a Reply

Your email address will not be published. Required fields are marked *