List VM:s which are backed up by job.

PowerShell script exchange

List VM:s which are backed up by job.

Veeam Logoby mikkoj » Sun Dec 11, 2016 8:43 pm

Hello,

Long story short: is there easy way to report all VM:s certain backup job actually works on?
Not this option:
$job = get-vbrjob JOBNAME
$job.getobjectsinjob()
because it does not show virtual machines in containers, such as vCenter object or folder.

I'm having difficulties listing VM:s in backup jobs.
We have several backup jobs, both as inclusions and exclusions we use both single VMs, and folders or other containers.
For example one job has vCenter server as included object, and several VMs and folders as exclusion.
Getting list of items in jobs is simple, and from there I can select included or excluded objects. But the problem is how to get objects under vCenter or folder.

I thought that workaround for this would be pulling list of VMs from vCenter using powercli and cross referensing list of excluded VMs and included vms and/or vms under certain object.

But this will be awful mess of a script.

-Mikko
mikkoj
Novice
 
Posts: 4
Liked: 2 times
Joined: Sun Dec 11, 2016 1:05 pm
Full Name: Mikko Jarva

Re: List VM:s which are backed up by job.

Veeam Logoby Vitaliy S. » Sun Dec 11, 2016 8:47 pm

Hi Mikko,

While you're waiting for assistance from PowerShell experts, try to take a look at these predefined reports in Veeam ONE, should help: VM Backup Status and Protected VMs.

Thanks!
Vitaliy S.
Veeam Software
 
Posts: 19960
Liked: 1145 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: List VM:s which are backed up by job.

Veeam Logoby mikkoj » Sun Dec 11, 2016 9:16 pm 1 person likes this post

Hello Vitaliy,

thank you for the reply, Veeam ONE reports are not an option in this case, for I need to build automatic report mechanism for several environements, of which all do not have Veeam ONE. And Veeam ONE free does not allow modifying reports, or sending them automatically (as far as I know).

-Mikko
mikkoj
Novice
 
Posts: 4
Liked: 2 times
Joined: Sun Dec 11, 2016 1:05 pm
Full Name: Mikko Jarva

Re: List VM:s which are backed up by job.

Veeam Logoby Mike Resseler » Mon Dec 12, 2016 7:46 am

Mikko,

Might not be what you exactly meant but:

* Modifying reports in Veeam ONE: https://helpcenter.veeam.com/docs/one/r ... tml?ver=95
* Publishing them automatically: https://helpcenter.veeam.com/docs/one/r ... tml?ver=95 (on a URL)
* Sending them automatically: https://helpcenter.veeam.com/docs/one/r ... tml?ver=95

Brgds,
Mike
Mike Resseler
Veeam Software
 
Posts: 3382
Liked: 384 times
Joined: Fri Feb 08, 2013 3:08 pm
Location: Belgium, the land of the fries, the beer, the chocolate and the diamonds...
Full Name: Mike Resseler

Re: List VM:s which are backed up by job.

Veeam Logoby tdewin » Mon Dec 12, 2016 9:34 am

Hi,

You can take a look at the last session and it's task sessions
Code: Select all
$session = $job.FindLastSession()
$session.GetTaskSessions()
tdewin
Veeam Software
 
Posts: 1108
Liked: 390 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: List VM:s which are backed up by job.

Veeam Logoby mikkoj » Mon Dec 12, 2016 9:42 am

Hello,

thank you for replies.
Mike: scheduling reports seemingly works on Veeam ONE free: you can create schedule for report, but it is not sent. We do not have full Veeam ONE in every environment. Hence PowerShell, and further powershell version can be integrated to other reports.

tdewin: this might be right direction. But how can I find the last "proper" run, not the retry runs?

-Mikko
mikkoj
Novice
 
Posts: 4
Liked: 2 times
Joined: Sun Dec 11, 2016 1:05 pm
Full Name: Mikko Jarva

Re: List VM:s which are backed up by job.

Veeam Logoby tdewin » Mon Dec 12, 2016 9:51 am

You can actually use get-vbrbackupsession to return all session and on that session you can get-vbrtasksession
https://helpcenter.veeam.com/backup/pow ... ssion.html
https://helpcenter.veeam.com/backup/pow ... ssion.html
tdewin
Veeam Software
 
Posts: 1108
Liked: 390 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: List VM:s which are backed up by job.

Veeam Logoby v.Eremin » Mon Dec 12, 2016 12:36 pm

Does this thread look like something you're after? Thanks.
v.Eremin
Veeam Software
 
Posts: 13709
Liked: 1026 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: List VM:s which are backed up by job.

Veeam Logoby mikkoj » Fri Dec 16, 2016 6:53 pm 1 person likes this post

Hello,

Thanks for replies. Thread posted by v.Eremin is definitely interesting, however tdewins get-vbrbackupsession and get-vbrtasksession were solution I was looking for.
Script below gives list of all VMs in selected jobs, and job names. After that it'll be quite simple to do outputs as needed. Getting correct lists of objects required getting retry -jobs out from vbrbackupsession -list.
Code: Select all
add-pssnapin veeampssnapin

$jobs = get-vbrjob -name PATTERN_FOR_JOB_NAMES*

$vms_in_jobs = new-object System.Collections.ArrayList
$allsessions = get-vbrbackupsession

foreach ($job in $jobs){
    echo $job.name
    $vms_protected_by_job = $null
    $vms_protected_by_job = ($allsessions | where {($_.jobname -like $job.Name) -and ($_.name -notlike "*Retry*") } | sort-object CreationTimeUTC -Descending)[0] | get-vbrtasksession
    foreach ($vm_protected_by_job in $vms_protected_by_job){
        $vm_in_job = New-Object PSObject
        Add-Member -InputObject $vm_in_job -MemberType NoteProperty -Name Name -Value $vm_protected_by_job.name
        Add-Member -InputObject $vm_in_job -MemberType NoteProperty -Name JobName -value $vm_protected_by_job.jobname
        $vms_in_jobs.add($vm_in_job) | out-null
    }
   
}


$vms_in_jobs_compare1 = $vms_in_jobs.name
$vms_in_jobs_compare2 = $vms_in_jobs_compare1 | select -unique
Compare-Object $vms_in_jobs_compare1 $vms_in_compare2
mikkoj
Novice
 
Posts: 4
Liked: 2 times
Joined: Sun Dec 11, 2016 1:05 pm
Full Name: Mikko Jarva

[MERGED] Checking which servers aren't in a backup job

Veeam Logoby pshute » Mon Jan 09, 2017 1:50 am

Is there any way to get a list of servers that aren't included in a backup job?

When I add a server to an existing backup job, I have to choose from the list of all servers on the cluster. It would be nice if there was some indication of which ones are already included in the job.
pshute
Expert
 
Posts: 118
Liked: 8 times
Joined: Mon Nov 23, 2015 10:56 pm
Full Name: Peter Shute

Re: List VM:s which are backed up by job.

Veeam Logoby PTide » Mon Jan 09, 2017 8:28 am 1 person likes this post

Hi,

You can either use one of the abovementioned PS scripts, or stick with one of Veeam ONE reports.

Thanks
PTide
Veeam Software
 
Posts: 3245
Liked: 272 times
Joined: Tue May 19, 2015 1:46 pm

Re: List VM:s which are backed up by job.

Veeam Logoby pshute » Mon Jan 09, 2017 10:02 am

PTide wrote:Hi,

You can either use one of the abovementioned PS scripts, or stick with one of Veeam ONE reports.

Thanks


Thanks. Can I please suggest as an enhancement to Backup & Replication that when one is selecting servers to include in a job, that it flags those already in the job? Even if I write a script to list them, I'd still have to carefully compare the list with the list on screen. That seems a bit hit and miss.
pshute
Expert
 
Posts: 118
Liked: 8 times
Joined: Mon Nov 23, 2015 10:56 pm
Full Name: Peter Shute

Re: List VM:s which are backed up by job.

Veeam Logoby vmniels » Mon Jan 09, 2017 10:04 am

You can always modify the job to use objects like folders or datastores so you don't have to manually add the servers to the job.
VCP-DCV
Veeam Certified Architect (VMCA)
http://foonet.be
vmniels
Veeam Software
 
Posts: 1630
Liked: 362 times
Joined: Mon Jul 15, 2013 11:09 am
Full Name: Niels Engelen

Re: List VM:s which are backed up by job.

Veeam Logoby pshute » Mon Jan 09, 2017 9:30 pm

vmniels wrote:You can always modify the job to use objects like folders or datastores so you don't have to manually add the servers to the job.


Thanks, I didn't know you could do that. We already have a folder for servers. I will discuss with colleagues whether we should change to that method of vm selection. It has the disadvantage that a machine will be left out if it's placed in the wrong folder, and until now placement has been done by people not involved with backups. I can see a couple out of place now. It hasn't mattered in the past, so it would require a change of culture to make it reliable.

Can you use both methods at the same time? That might be a good compromise - we could specifically include particular machines, and use the folders to catch any forgotten ones.

I would still like to see machines highlighted in the selection list if they're already in the job. It just seems like a good thing to have as a double check. I don't think I've ever come across any other backup software where you don't just tick a box beside each object - if it's already ticked then it's already included.
pshute
Expert
 
Posts: 118
Liked: 8 times
Joined: Mon Nov 23, 2015 10:56 pm
Full Name: Peter Shute

Re: List VM:s which are backed up by job.

Veeam Logoby Mike Resseler » Tue Jan 10, 2017 6:28 am

Hi Peter,

Yes, you can use different methods at the same time.
Mike Resseler
Veeam Software
 
Posts: 3382
Liked: 384 times
Joined: Fri Feb 08, 2013 3:08 pm
Location: Belgium, the land of the fries, the beer, the chocolate and the diamonds...
Full Name: Mike Resseler

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 1 guest