cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

Backup all alerts

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?

Labels (1)
Tags (1)
0 Kudos
12 Replies
Level 12

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!

0 Kudos

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

Which tables need to be backed up?

0 Kudos

Orion.AlertConfigurations  

There is an export verb available.

0 Kudos

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).

0 Kudos

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

Level 16

pastedImage_0.png

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.

0 Kudos

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.

0 Kudos