Last active
March 24, 2019 17:20
-
-
Save jaapbrasser/262217968b9e0ec73073b147908cf9ff to your computer and use it in GitHub Desktop.
Weekly Rubrik Backup Job - Issue 667
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MAIN | |
$sla = 'S3_Weekly_cloud_archive' | |
# Source SLA seperated by comma | |
#Example - $sourceslas = ('SQL_Base','SLA2') | |
$sourceslas = ('BASE_SLA') | |
$rubrik = '*.*.*.*' | |
. "D:\ctm_jobs\Rubrik\Write-Log.ps1" | |
connect_rubrik($rubrik) | |
foreach ($sourcesla in $sourceslas) { | |
$dbs = Get-RubrikDatabase | ? {$_.effectiveSlaDomainName -like $sourcesla} | |
$vms = Get-RubrikVM -SLA $sourcesla | |
$vols = Get-RubrikVolumeGroup -SLA $sourcesla | |
#$servers = Get-RubrikHost | |
write-host "Reading DB List" | |
Write-Log -sla $sla -Message "Reading DB List" -Severity Information | |
$dbcount = $dbs.count | |
if ($dbcount -gt 0) { | |
foreach ($db in $dbs){ | |
$evt = "Will Backup Database: " + $db | |
write-Log -sla $sla -Message $evt | |
} | |
} | |
write-host "Reading Vol Group List" | |
Write-Log -sla $sla -Message "Reading Vol List" -Severity Information | |
$volcount = $vols.count | |
if ($volcount -gt 0) { | |
foreach ($vol in $vols){ | |
$evt = "Will Backup Volumes: " + $vol | |
write-Log -sla $sla -Message $evt | |
} | |
} | |
write-host "Reading VM List" | |
$vmcount = $vms.count | |
if ($vmcount -gt 0){ | |
foreach ($vm in $vms){ | |
$evt = "Will Backup VM: " + $vm | |
Write-Log -sla $sla -Message $evt -Severity Information | |
} | |
} | |
$i = 0 | |
$task = "" | |
#cls | |
Write-Log -sla $sla -Message "Starting Database Backups" -Severity Information | |
Write-Host "Starting Database Backups" -ForegroundColor Blue -BackgroundColor Yellow | |
while ($i -lt $dbcount){ | |
$task = Get-RubrikDatabase -id $dbs[$i].id | new-rubriksnapshot -sla $sla -confirm:$false -ErrorAction SilentlyContinue | |
write-host $task | |
$evt = "Backing up database: " + $dbs[$i].name | |
Write-Log -sla $sla -Message $evt -Severity Information | |
$i+=1 | |
} | |
Write-Log -sla $sla -Message "Starting VM Backups" -Severity Information | |
Write-Host "Starting VM Backups" -ForegroundColor Blue -BackgroundColor Yellow | |
$i = 0 | |
while ($i -lt $vmcount){ | |
$task = Get-Rubrikvm -id $vms[$i].id | new-rubriksnapshot -sla $sla -confirm:$false -ErrorAction SilentlyContinue | |
write-host $task | |
$evt = "Backing up database: " + $vms[$i].name | |
Write-Log -sla $sla -Message $evt -Severity Information | |
$i+=1 | |
} | |
Write-Log -sla $sla -Message "Starting PhysicalBackups" -Severity Information | |
Write-Host "Starting Physical Backups" -ForegroundColor Blue -BackgroundColor Yellow | |
$i = 0 | |
while ($i -lt $volcount){ | |
$task = Get-Rubrikvolumegroup -sla $sla -id $vols[$i].id | new-rubriksnapshot -sla $sla -confirm:$false -ErrorAction SilentlyContinue | |
write-host $task | |
$evt = "Backing up Server: " + $vols[$i].name | |
Write-Log -sla $sla -Message $evt -Severity Information | |
$i+=1 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment