PowerShell script exchange
Post Reply
mikkoj
Novice
Posts: 4
Liked: 2 times
Joined: Dec 11, 2016 1:05 pm
Full Name: -
Contact:

List VM:s which are backed up by job.

Post by mikkoj »

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
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

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

Post by Vitaliy S. »

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!
mikkoj
Novice
Posts: 4
Liked: 2 times
Joined: Dec 11, 2016 1:05 pm
Full Name: -
Contact:

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

Post by mikkoj » 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
Mike Resseler
Product Manager
Posts: 8044
Liked: 1263 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

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

Post by Mike Resseler »

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
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

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

Post by tdewin »

Hi,

You can take a look at the last session and it's task sessions

Code: Select all

$session = $job.FindLastSession()
$session.GetTaskSessions()
mikkoj
Novice
Posts: 4
Liked: 2 times
Joined: Dec 11, 2016 1:05 pm
Full Name: -
Contact:

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

Post by mikkoj »

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
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

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

Post by tdewin »

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
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

Does this thread look like something you're after? Thanks.
mikkoj
Novice
Posts: 4
Liked: 2 times
Joined: Dec 11, 2016 1:05 pm
Full Name: -
Contact:

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

Post by mikkoj » 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
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

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

Post by pshute »

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.
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

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

Post by PTide » 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
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

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

Post by pshute »

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.
nielsengelen
Product Manager
Posts: 5619
Liked: 1177 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

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

Post by nielsengelen »

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.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

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

Post by pshute »

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.
Mike Resseler
Product Manager
Posts: 8044
Liked: 1263 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

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

Post by Mike Resseler »

Hi Peter,

Yes, you can use different methods at the same time.
nilayjoshi
Lurker
Posts: 1
Liked: never
Joined: Jan 11, 2017 12:43 am
Full Name: Nilay
Contact:

[MERGED] Script to see which VM's are getting backed up

Post by nilayjoshi »

Hello,

I am looking for Power Shell Script for B&R 9.5 Version that will give me output of List of VM's on my VMware Environment are getting backed up and which ones aren't getting backed up. If there is report query in the Veeam that is available that would help as well.

Thank You
Nilay
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Script to see which VM's are getting backed up

Post by Vitaliy S. »

Hi Nilay,

Please take a look at these topics for the answer > one you've been merged into and this one

Thanks!
albertwt
Veeam Legend
Posts: 879
Liked: 46 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

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

Post by albertwt »

I'd like to know how can I get the backup report from Veeam Backup to see:
Hi All,

Can anyone here please share the Powershell script to list or export:
Which VM is backed up
What's the Backup frequency
Where the backup is saved/stored
How long is the retention policy for the VM backup to be retained

Thanks in advance.
--
/* Veeam software enthusiast user & supporter ! */
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests