Comprehensive data protection for all workloads
Post Reply
gjg_allegis
Novice
Posts: 7
Liked: 3 times
Joined: Nov 25, 2020 6:23 pm
Contact:

Preview Backup Job VM Selection

Post by gjg_allegis »

Anyone know of a way to see the actual list of VMs that would be selected when setting up a backup job, before the backup job actually runs? I'm trying to setup a job that only backs up VM templates and it's saying it would be about 36TB of data, but that is way too high. I suspect there might be a problem with the exclusion settings in the job, so I would like to see the list of VMs being selected without running the job.
Mildur
Product Manager
Posts: 9787
Liked: 2585 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Preview Backup Job VM Selection

Post by Mildur »

Hi

How have you added the templates to the backup job? One by one, a tag or a folder?

Best,
Fabian
Product Management Analyst @ Veeam Software
gjg_allegis
Novice
Posts: 7
Liked: 3 times
Joined: Nov 25, 2020 6:23 pm
Contact:

Re: Preview Backup Job VM Selection

Post by gjg_allegis »

For this job, the VM selection points to a particular ESX host cluster, and then there is a bunch of exclusions based on tags and folders. The intention is to catch any VMs (templates and newly provisioned ones) that aren't specifically included in another backup job. I was hoping I could look through a log that would show the VM names selected after it showed the capacity number when setting up the job. It's not a big deal, I'm just used to having the preview option after working with other backup software.
DChiavari
VeeaMVP
Posts: 1122
Liked: 309 times
Joined: Feb 02, 2012 7:03 pm
Full Name: Danilo Chiavari
Location: Rome, IT
Contact:

Re: Preview Backup Job VM Selection

Post by DChiavari » 1 person likes this post

With some great help by @oleg.feoktistov I was able to put together the following script, re-using some code I wrote years ago for another project...

What the script does:
  • Get the objects / containers in the job's selection list (hosts, clusters, VMs, whatever)
  • Find all VMs inside those objects
  • List them in a table, along with their path/location, provisioned and used size

Code: Select all

#Specify the source job
$source_job = Get-VBRJob -Name "YOUR_JOB_NAME"

Write-Host -ForegroundColor Yellow "Processing job: $($source_job.Name)"`n

#Get the objects in the job's selection list
$source_job_objects = Get-VBRJobObject -Job $source_job

Write-Host -ForegroundColor Cyan "List of containers and items in the job selection list (count: $($source_job_objects.Count)): "
$source_job_objects | ft -Property Name, TypeDisplayName -AutoSize

#Initialize the array that will contain the VMs found in the job
$found_vms=@()

    #Cycle through each object and based on its type (VM/Host, Datacenter, Cluster, Host, Folder, Tag, etc.) find the VMs inside
    ForEach ($jobObject in $source_job_objects) {
                        
        Switch ($jobObject.TypeDisplayName) {
            {'Virtual Machine' -contains $_} {
                $found_vms += Find-VBRViEntity -Name $jobObject.Name
                }

            {'Host', 'Datacenter', 'Cluster' -contains $_} {
                $found_vms += Find-VBRViEntity | ? {($_.Path -like "$($jobObject.Location)*") -and ($_.Type -eq 'Vm')}
                }

            {'Folder', 'Template' -contains $_} {
                $found_vms += Find-VBRViEntity -VMsAndTemplates | ? {($_.Path -like "$($jobObject.Location)*") -and ($_.Type -eq 'Vm')}
                }
            
            {'Datastore', 'Datastore Cluster' -contains $_} {
                $found_vms += Find-VBRViEntity -DatastoresAndVMs | ? {($_.Path -like "$($jobObject.Location)*") -and ($_.Type -eq 'Vm')}
                }

            {'Tag', 'Tag Category' -contains $_} {
                $found_vms += Find-VBRViEntity -Tags | ? {($_.Path -like "$($jobObject.Location)*") -and ($_.Type -eq 'Vm')}
                }
        }
    }

    Write-Host -ForegroundColor Cyan "List of VMs found in the job (count: $($found_vms.Count)): "

    $found_vms| ft Name, Type, Path, @{n="Provisioned GB";e={[math]::Round($_.ProvisionedSize/1GB,0)}}, @{n="Used GB";e={[math]::Round($_.UsedSize/1GB,0)}} -AutoSize
Sample output:

Image
Danilo Chiavari
Presales Manager - Italy

www.danilochiavari.com
gjg_allegis
Novice
Posts: 7
Liked: 3 times
Joined: Nov 25, 2020 6:23 pm
Contact:

Re: Preview Backup Job VM Selection

Post by gjg_allegis » 2 people like this post

I ran the script and it did the trick. Not only that but it's a great example of using Find-VBRViEntity. Thank you so much, this is very helpful.
Post Reply

Who is online

Users browsing this forum: acmeconsulting, Bing [Bot], mjr.epicfail, Regnor and 108 guests