85 lines
2.5 KiB
PowerShell
85 lines
2.5 KiB
PowerShell
##########################################################################
|
|
#
|
|
# On Demand Snapshot for all Oracle DBs with a specific SLA
|
|
# Created by Rubrik PS for McDermott, September 2025
|
|
#
|
|
# Must be run with a Global service account.
|
|
#
|
|
# Requires RubrikSecurityCloud module to be installed and working against
|
|
# a Global Service Account with Administrator rights.
|
|
#
|
|
# Create the service account file with:
|
|
# Set-RscServiceAccountFile sa.json -OutputFilePath Global.xml
|
|
#
|
|
# Example invocation
|
|
# .\monthlySnap.ps1 -sourceSla "Prod Oracle SLA" -triggerSla "Oracle Monthly Only"
|
|
#
|
|
# v0.1 Initial Release
|
|
#
|
|
##########################################################################
|
|
|
|
param (
|
|
[Parameter(Mandatory=$True,
|
|
HelpMessage="Name of SLA to query")]
|
|
[string]$sourceSla,
|
|
|
|
[Parameter(Mandatory=$True,
|
|
HelpMessage="Name of SLA to trigger")]
|
|
[string]$triggerSla
|
|
)
|
|
|
|
$GlobalSAFile = "C:\Rubrik\james.xml"
|
|
|
|
###########################
|
|
# Script begins
|
|
###########################
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
Import-Module RubrikSecurityCloud
|
|
|
|
Connect-Rsc -ServiceAccountFile $GlobalSAFile
|
|
|
|
Write-Host "INFO: Getting Tenant details"
|
|
|
|
$srcSla = Get-RscSla -Name $sourceSla
|
|
if (-not $srcSla) {
|
|
Write-Error "ERROR: No source SLA found with name '$sourceSla'. Exiting script."
|
|
Disconnect-Rsc
|
|
exit 1
|
|
}
|
|
|
|
$monthlySla = Get-RscSla -Name $triggerSla
|
|
if (-not $monthlySla) {
|
|
Write-Error "ERROR: No monthly SLA found with name '$triggerSla'. Exiting script."
|
|
Disconnect-Rsc
|
|
exit 1
|
|
}
|
|
|
|
$query = New-RscQuery -GqlQuery protectedObjectsConnection
|
|
$query.Var.slaIds = @($srcSla.Id)
|
|
$query.var.filter = @(Get-RscType -Name Filter)
|
|
$query.var.filter[0].field = "IS_RELIC"
|
|
$query.var.filter[0].Texts = "false"
|
|
|
|
$protectedObjects = $query.invoke()
|
|
|
|
$protectedObjects.Nodes | ForEach-Object {
|
|
|
|
Write-Host "Triggering Backup for Name: $($_.Name), Id: $($_.Id)"
|
|
|
|
$oracleDb = Get-RscOracleDatabase -name "example"
|
|
|
|
$query = New-RscMutation -GqlMutation takeOnDemandOracleDatabaseSnapshot
|
|
$query.Var.input = Get-RscType -Name TakeOnDemandOracleDatabaseSnapshotInput -InitialProperties config.baseOnDemandSnapshotConfig
|
|
$query.Var.input.id = $_.Id
|
|
$query.Var.input.Config.forceFullSnapshot = $false
|
|
$query.Var.input.Config.baseOnDemandSnapshotConfig.slaId = $monthlySla.id
|
|
$query.Field = Get-RscType -Name AsyncRequestStatus -InitialProperties id
|
|
$result = $query.Invoke()
|
|
|
|
Write-Host "Backup triggered for Name: $($_.Name), Id: $result.Id"
|
|
|
|
}
|
|
|
|
Disconnect-Rsc |