PowerShell script exchange
Post Reply
rimvydukas
Enthusiast
Posts: 94
Liked: 6 times
Joined: Jun 04, 2013 8:15 am
Contact:

Feature request: exclusions filters

Post by rimvydukas »

Another feature request :) Lets imagine that I have two backup jobs created. One job archives Windows VMs and another Linux VMs. With currecnt program implementation I'm able to achieve this if I'll exclude all Linux machines in one job and if I'll exclude all Windows machines in another job. As I can understand - I must do all of these exclusions manualy or am I wrong? It would be nice to have some kind of exclusions filtering ability, for example I salect to archive one esx host and apply filter to skip all Linux machines. So in case when someone will create new linux machine it will be skiped automaticly by the job which archives windows machines. I'll not be forced to make any exclusions by myself.
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature request: exclusions filters

Post by veremin »

Unfortunately, it’s not possible with the current VB&R version. However, you can always become a little creative and utilize custom PS script that, once executed, will find and exclude any linux/window machine present within a given job.

Thanks.
rimvydukas
Enthusiast
Posts: 94
Liked: 6 times
Joined: Jun 04, 2013 8:15 am
Contact:

Re: Feature request: exclusions filters

Post by rimvydukas »

Can you point me to such a script:) And then again - maybe another feature request?:)
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature request: exclusions filters

Post by veremin »

The discussion has been moved to the corresponding sub forum.
Can you point me to such a script
Yep, the following script might answer your requirements:

Code: Select all

Asnp VMware.VimAutomation.Core
Asnp VeeamPSSnapin
Connect-VIServer -Server "Name of your vCenter" -User "User name" -Password "Password"
$Objects = Get-VBRJob -name "Name of your job" | Get-VBRJobObject 
Foreach ($Object in $Objects)
{
   If (((Get-VM -name $Object.name | Get-View).summary.config.guestFullName) -notmatch "Windows")
   {
    $Object | Remove-VBRJobObject 
   }
}   


This script will exclude from a given job VMs which operating system isn’t Windows.

Hope this helps.
Thanks.
rimvydukas
Enthusiast
Posts: 94
Liked: 6 times
Joined: Jun 04, 2013 8:15 am
Contact:

Re: Feature request: exclusions filters

Post by rimvydukas »

Thank you for this script very much. Bu I hope that you'll be able to implement more advanced filtering options via GUI in the near future:)
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature request: exclusions filters

Post by veremin »

Glad that you find this script useful. As to the features, all of them are prioritized in accordance with customers’ demand. So, thank you for the feedback; much appreciated.
rimvydukas
Enthusiast
Posts: 94
Liked: 6 times
Joined: Jun 04, 2013 8:15 am
Contact:

Re: Feature request: exclusions filters

Post by rimvydukas »

Ok, tried this script. It seems that it works, but....

...but problem is that my job has two esx servers selected and not virtual machines selected. In that case script does not work. What are my options then?
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature request: exclusions filters

Post by veremin »

...but problem is that my job has two esx servers selected and not virtual machines selected
You mean that ESX(i) hosts where given VMs reside on have been added to backup console as standalone host and not as a part of vCenter? Thanks.
rimvydukas
Enthusiast
Posts: 94
Liked: 6 times
Joined: Jun 04, 2013 8:15 am
Contact:

Re: Feature request: exclusions filters

Post by rimvydukas »

v.Eremin wrote:You mean that ESX(i) hosts where given VMs reside on have been added to backup console as standalone host and not as a part of vCenter? Thanks.
No,

All of ESX servers are part of vcenter server. Problem is, that when I create backup job I select ESXi servers to backup (virtual machines to backup window), not individual VM machines. I want to have a flexible situation - when new VM appears on this esxi - it is backed up automatically without any additional intervention. And in this case script doesn't work, as it expects to have VMs in job settings and not ESXi servers.
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature request: exclusions filters

Post by veremin »

Then, it seems that there is no supported way how you can achieve it. For now you can probably take the following algorithm and implement it in your script, however, do it on your own risk:

Code: Select all

Asnp VMware.VimAutomation.Core
Asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of Your backup Job"
$Repo = Get-VBRBackupRepository -name "Name of your Repository"
$Server = Get-VBRServer -name "Name of your ESX(i) host"
$ESXServer = Get-VBRJob -name $Job.name | Get-VBRJobObject 
Connect-VIServer -Server $ESXServer.name -User "User" -Password "Password"
$Object = Get-VM | where {(($_ |Get-View).summary.config.guestFullName) -notmatch "Windows"}
$ObjectsToExclude = Find-VBRViEntity -Server $Server -name $Object.name
Add-VBRViBackupJob -Name "Temprorary Job" -BackupRepository $Repo -Entity $ObjectsToExclude
$Job1 = Get-VBRJob -name "Temprorary Job"
Foreach ($VmToExclude in ($Job1 | Get-VBRJobObject))
{
$VmToExclude.name
[Veeam.Backup.Core.CObjectInJob]::CreateViOij($Job.Id.guid, $VmToExclude.Object.Id.Guid, $VmToExclude.info.folderId, $VmToExclude.info.VssOptions, $VmToExclude.info.ApproxSize, $VmToExclude.info.Location, $VmToExclude.info.type,$VmToExclude.info.DiskFilter, $False)
$Objects = Get-VBRJob -name $Job.name | Get-VBRJobObject | ?{$_.name -eq $VmToExclude.name}
$Objects | Remove-VBRJobObject
$Objects.delete()
}
Remove-VBRJob -Job $Job1 -Confirm:$False

Hope this helps.
Thanks.
rimvydukas
Enthusiast
Posts: 94
Liked: 6 times
Joined: Jun 04, 2013 8:15 am
Contact:

Re: Feature request: exclusions filters

Post by rimvydukas »

Ok, thanks for the script, I'll try to understand it:) But please, implement more advanced filtering in your product:)
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature request: exclusions filters

Post by veremin »

Ok, thanks for the script, I'll try to understand it:)
Feel free to ask any question and I will be glad to assist you in your understanding.

Generally speaking, I’ve just implemented the algorithm mentioned above. So:

• Firstly, it connects to ESX(i) server and finds VMs which OS isn’t windows.
• Secondly, a temp job is being created (“Temporary job”)
• Thirdly, VMs collected at step 1, are added to the temp job.
• Fourthly, for each VM script creates object of the ”CObjectInJob” type.
• Fifthly, these objects are excluded from a given job.
• Finally, the temp job is deleted.
But please, implement more advanced filtering in your product:)
Got your point. :) Thanks again for the feedback.
talanx
Lurker
Posts: 1
Liked: never
Joined: Nov 12, 2012 7:29 pm
Contact:

Re: Feature request: exclusions filters

Post by talanx »

Put the Windows VM's in one folder and the Linux VM's in another folder.
Exclude the Linux VM's folder from the Windows Job.
Exclude the Windows VM's folder from the Linux Job.
rimvydukas
Enthusiast
Posts: 94
Liked: 6 times
Joined: Jun 04, 2013 8:15 am
Contact:

Re: Feature request: exclusions filters

Post by rimvydukas »

I use folders for a logical grouping of my VMs, so I can't do that.
decoy5657
Influencer
Posts: 12
Liked: 3 times
Joined: Oct 09, 2013 2:45 pm
Full Name: Aaron Anderson
Contact:

[MERGED] : Exclude VM's from job that backs up entire Cluste

Post by decoy5657 »

I have a job that backs up an entire cluster named "Development" - I need to be able to add exclusions to this job based on the name of the machine. IE, I want to exclude machines that match

Code: Select all

"*b" 
I have gotten some scripts that work, but only if the "objects in the job" are a full list of virtual machines, which isn't much help since my only object is an entire cluster.

any help would be appreciated.
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature request: exclusions filters

Post by veremin »

Hi, Aaron.

I’ve already created a script that does something similar to what you’ve requested with the only exception that the script covers the case with ESX(i) host instead of cluster. So, if you modify it a little bit, it will meet your requirements.

Thanks.
decoy5657
Influencer
Posts: 12
Liked: 3 times
Joined: Oct 09, 2013 2:45 pm
Full Name: Aaron Anderson
Contact:

Re: Feature request: exclusions filters

Post by decoy5657 »

Code: Select all

Add-PSSnapin VMware.VimAutomation.Core
Add-PSSnapin VeeamPSSnapin
Connect-VIServer server.local.lan

Clear-Host

$DevClusterVMsToAdd = Get-Cluster "Development" | Get-VM | Where-Object {$_.Name -notlike "*b"}
Add-VBRJobObject -Job "Development" -Server server.local.lan -Objects $DevClusterVMsToAdd

$ProductionClusterVMsToAdd = Get-Cluster "Production" | Get-VM | Where-Object {$_.Name -notlike "*b"}
Add-VBRJobObject -Job "Production" -Server server.local.lan -Objects $ProductionClusterVMsToAdd
To solve my problem I used the above script. I just have to ensure that it runs on a regular basis to get new machines into the job. The only problem I see is that it says "Add-VBRJobObject" is outdated and to use "Add-VBRViJobObject" instead. "Add-VBRViJobObject" doesn't use "-Objects" it requires "-Entities" and I can't pipe in machine names from the get-cluster and get-vm commands.
decoy5657
Influencer
Posts: 12
Liked: 3 times
Joined: Oct 09, 2013 2:45 pm
Full Name: Aaron Anderson
Contact:

Re: Feature request: exclusions filters

Post by decoy5657 »

v.Eremin wrote:Hi, Aaron.

I’ve already created a script that does something similar to what you’ve requested with the only exception that the script covers the case with ESX(i) host instead of cluster. So, if you modify it a little bit, it will meet your requirements.

Thanks.

This? http://forums.veeam.com/viewtopic.php?f ... 021#p81321
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature request: exclusions filters

Post by veremin »

Yep, you have to:

• Firstly, connect to vCenter server and find VMs that reside on a given cluster and that have names starting with “b”.
• Secondly, create a temp job (“Temporary job”).
• Thirdly, add to the temp job VMs collected at step 1.
• Fourthly, for each VM create object of the ”CObjectInJob” type.
• Fifthly, exclude the said objects from a given job.
• Finally, delete temporary job.

Hope this helps.
Thanks.
electricd7
Expert
Posts: 122
Liked: 7 times
Joined: Mar 27, 2012 10:13 pm
Full Name: Chad Killion
Contact:

[MERGED] Looking for an easy way to add an exclusion to all

Post by electricd7 »

Hello,

I have a client with a large number of backups. All jobs are setup to backup entire datastores. Sometimes they will storageVmotion disks within individual machines to different datastores. There are certain machines which are excluded from backups but when they move the disks to other datstores those machines get picked up by the other datastore job because there are no exclusions. I am looking for a way to write a script which will take VM names or Folders as inputs and will add (or verify if already added) those to the exclusions for either a given job or for all jobs. Can this be done easily?
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature request: exclusions filters

Post by veremin »

Hi, I have already created the script that excludes certain VMs out of the backup job, in case where container (folder, datastore) is selected as the job object. The only thing that has to be modified here is $ObjectsToExclude variable.

Please, take a look and ask if any additional help is needed.

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests