I'm looking for a way to bakup all of my alerts. In the event that say a single alert is deleted or modified incorrectly I would like to be able to restore the alert without doing a full server restore. What it the proper method for doing this as I can't check multiple alerts for export?
Here you go! This is a nice little powershell script to backup all ACTIVE (a.k.a. Enabled) alerts from your Orion instance.
I have this run as a daily scheduled task.
# --- POWERSHELL ---
# --- Requires the source machine where script runs has the OrionSDK installed. ---
# --- Download binaries from here: https://github.com/solarwinds/OrionSDK ---
#
# Requirements:
# Create an Orion basic user that has "Alert management rights" enabled.
# That's about it.
#
# Verify OrionSDK SwisSnapin presence
if (!(Get-PSSnapin -Name "SwisSnapin" -ErrorAction SilentlyContinue))
{
Add-PSSnapin SwisSnapin -ErrorAction SilentlyContinue
}
# Define Variables
$swis = Connect-Swis -Hostname my-orion-host.domain.com -Username alertbackup -Password Jello12#
# Get all AlertId
$AlertList = Get-SwisData $swis "SELECT AlertId FROM Orion.AlertConfigurations WHERE Enabled = True"
$AlertIds = $AlertList -split ' '
foreach($alertid in $AlertIds){
$alerttitle = Get-SwisData $swis "SELECT Name FROM Orion.AlertConfigurations WHERE AlertId = $alertid"
$alerttitle = $alerttitle -replace '(#|\||"|,|/|:|\<|\>|\[|\]|%|$|@|â|€|™|\?)', ''
$alerttitle = $alerttitle -replace '\s','_'
$filename = "$alerttitle-ID-$alertid.xml"
Set-Content $filename $ExportedAlert.InnerText
$ExportedAlert = Invoke-SwisVerb $swis Orion.AlertConfigurations Export @($alertid)
}
(Edit --- was missing closing bracket on line 32)
This is great many thanks!
My pleasure!
I went ahead and posted this in a formal way. A few extra notes, yada yada - Full Orion alert rule export using Powershell and OrionSDK
This is possible via the SDK;
Which tables need to be backed up?
Orion.AlertConfigurations
There is an export verb available.
This won't get all the associated actions though. I wasn't clear on my initial request though that I'm looking for a way to fully recreate the alert (actions included).
The export verb for that table should also provide the proper details for rebuilding/migrating, which does include the Trigger & reset Actions.
When you do a manual export of the alert(Web gui) you do get full details in that xml file and from what I can tell the Web Export option is using that export verb.
The table itself is broken out so it looks like some details are missing, so export is the function to get all info for a full rebuild.
You can't just copy the data from that table, you have to use the export verb.
I believe v12.0 and later will have the export verb option to get the AlertCofnigurations details in bulk rather than having to export them 1 by 1 from the web.
Hello,
Cahunt is right, you can use Orion SDK and create script which export all alerts via "Orion.AlertConfigurations.Export" VERB.
Lada
You can import/export them individualy
Thanks, but looking for a way to bulk export them all at once, or as a scheduled task if possible.
I was looking for this answer again today. Google led me here, two years later almost to the day. It's as though Google is mocking me.
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 150,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.