Permalink
Browse files

Changed license to MIT license instead of GPL v3

  • Loading branch information...
dellock6 committed May 31, 2016
1 parent 1be671a commit 71c357e0d9459bc89f47db569d23b181615bcad2
Showing with 96 additions and 29 deletions.
  1. +44 −21 dynamic-surebackup.ps1
  2. +28 −5 protected-vms.ps1
  3. +24 −3 veeam-backupjob-creator.ps1
@@ -1,11 +1,34 @@
#
# Dynamic Surebackup v 2.0
#
# Luca Dell'Oca - https://github.com/dellock6
# Released under GPL 3.0 license
####################################################################
#
# MIT License
#
#Copyright (c) 2016 Luca Dell'Oca
#
# Thanks to Hans Leysen for the major improvements
# in version 2.0
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
####################################################################

# Variables for script ------------------------
$AppGroupName = "Dynamic App Group"
@@ -17,30 +40,30 @@ $VirtualLab = "Virtual Lab 1"
[string]$VeeamBackupCounterFile = ".\hashtable.xml"
[int]$NumberofVMs = 20
###############################################

# Functions ------------------------------
Function selectUntestedVMs
{
param([string]$fVeeamBackupCounterFile,[int]$fNumberofVMs,$fVbrObjs)

$fHashtable = @{}
$fTestVMs = [System.Collections.ArrayList]@()
$fDeletedVMs = [System.Collections.ArrayList]@()

# Import VeeamBackupCounterfile if exists from a previous iteration
if(Test-Path $fVeeamBackupCounterFile)
{
$fHashtable = import-clixml $fVeeamBackupCounterFile
}

# Check if all VM's were tested
# if so the hashtable is cleared

if(!($fHashtable.Values -contains 0))
{
$fHashtable = @{}
}

# Add newly created VM's from backup
Foreach($fVbrObj in $fVbrObjs)
{
@@ -49,49 +72,49 @@ Function selectUntestedVMs
$fHashtable.Add($fVbrObj.name, "0")
}
}

# Remove old VM's from hashtable
$fHashtable.getEnumerator() | %{ if($fVbrObjs.name -notcontains $_.name) {$fDeletedVMs += $_.name}}
$fDeletedVMs | foreach{ $fHashtable.Remove($_)}

# Sort hashtable by Value
# Used new object because sorting the hashtable converts it to dictionary entry
$fHashtableOrdered = $fHashtable.GetEnumerator() | sort -Property "Value", "Name"

# Select least tested VMs and increment their value to 1 (tested)
for ($i = 0; $i -lt $fNumberofVMs; $i++)
{
$fTestVMs += $fHashtableOrdered[$i].Name
$fHashtable.Set_Item($fHashtableOrdered[$i].Name, 1)
}

#Save hashtable to file for the next iteration
$fHashtable | export-clixml $fVeeamBackupCounterFile

Return $fTestVMs

}
##########################################

asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue

# Check if there is no dynamic surebackup job running
if(!(get-vsbjob -Name "Dynamic Surebackup Job"))
{

# Find all VM objest successfully backed up in last 1 days
$VbrObjs = (Get-VBRBackupSession | ?{$_.JobType -eq "Backup" -and $_.EndTime -ge $Date}).GetTaskSessions() | ?{$_.Status -eq "Success" -or $_.Status -eq "Warning" }
# Call function selectUntestedVMs
$TestVMs = selectUntestedVMs -fVeeamBackupCounterFile $VeeamBackupCounterFile -fNumberofVMs $NumberofVMs -fVbrObjs $VbrObjs

# Create the new App Group, SureBackup Job, Start the Job
$VirtualLab = Get-VSBVirtualLab -Name $VirtualLab
$AppGroup = Add-VSBViApplicationGroup -Name $AppGroupName -VmFromBackup (Find-VBRViEntity -Name $TestVMs)
$VsbJob = Add-VSBJob -Name $SbJobName -VirtualLab $VirtualLab -AppGroup $AppGroup -Description $SbJobDesc

Start-VSBJob -Job $VsbJob

# Remove the old App Group
Remove-VSBJob -Job (Get-VSBJob -Name $SbJobName) -Confirm:$false
Remove-VSBApplicationGroup -AppGroup (Get-VSBApplicationGroup -Name $AppGroupName) -Confirm:$false
}
}
@@ -1,8 +1,31 @@
#
# Verify protected VM's
#
# Luca Dell'Oca - https://github.com/dellock6
# Released under GPL 3.0 license
####################################################################
#
# MIT License
#
#Copyright (c) 2016 Tom Sightler
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
####################################################################
#
# Run the script against vCenter and Veeam server and checks which VM's
# have been protected in the last 23 hours, and which are not protected
@@ -34,12 +57,12 @@ $HourstoCheck = 24
$excludevms_regex = ('(?i)^(' + (($excludeVMs | ForEach {[regex]::escape($_)}) -join "|") + ')$') -replace "\\\*", ".*"
$excludefolder_regex = ('(?i)^(' + (($excludeFolder | ForEach {[regex]::escape($_)}) -join "|") + ')$') -replace "\\\*", ".*"
$excludedc_regex = ('(?i)^(' + (($excludeDC | ForEach {[regex]::escape($_)}) -join "|") + ')$') -replace "\\\*", ".*"

$vms=@{}

# Build a hash table of all VMs. Key is either Job Object Id (for any VM ever in a Veeam job) or vCenter ID+MoRef
# Assume unprotected (!), and populate Cluster, DataCenter, and Name fields for hash key value
Find-VBRViEntity |
Find-VBRViEntity |
Where-Object {$_.Type -eq "Vm" -and $_.VmFolderName -notmatch $excludefolder_regex} |
Where-Object {$_.Name -notmatch $excludevms_regex} |
Where-Object {$_.Path.Split("\")[1] -notmatch $excludedc_regex} |
@@ -52,7 +75,7 @@ Find-VBRViEntity -VMsandTemplates |
ForEach {$vms.Add(($_.FindObject().Id, $_.Id -ne $null)[0], @("!", $_.Path.Split("\")[1], $_.VmHostName, $_.Name))}

# Find all backup task sessions that have ended in the last x hours and not ending in Failure
$vbrtasksessions = (Get-VBRBackupSession |
$vbrtasksessions = (Get-VBRBackupSession |
Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-$HourstoCheck)}) |
Get-VBRTaskSession | Where-Object {$_.Status -ne "Failed"}

@@ -1,9 +1,31 @@
#
# Veeam Backup Job Creator
#
# Luca Dell'Oca - https://github.com/dellock6
# Released under GPL 3.0 license
####################################################################
#
# MIT License
#
#Copyright (c) 2016 Luca Dell'Oca
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
####################################################################

#Retrieve the list of existing datastores as we want to create one job per datastore

@@ -53,4 +75,3 @@ Get-VBRJob -Name $datastorename | Set-VBRJobAdvancedStorageOptions -CompressionL

Get-VBRJob -Name $datastorename | Set-VBRJobSchedule -Daily -At $time
Get-VBRJob -Name $datastorename | Enable-VBRJobSchedule

0 comments on commit 71c357e

Please sign in to comment.