As part of my series how to back up your SCOM environment I ‘ve created a backup strategy for my unsealed management packs.
The setup I choose is to use a PowerShell script with error handling included which is run by the Task Scheduler on the RMS and monitored by a management pack in SCOM.
The advantages of this setup are:
The PowerShell script I used is based on the UnsealedMPbackup management pack which is posted here: https://skydrive.live.com/?cid=397bb61b75cc76c5&id=397BB61B75CC76C5%21217#
Although this is an excellent script I modified it to have Error handling in there. If you look at the script there’s also a mailer included in the script but it’s commented out for now. If you would like to use this as a standalone script without the monitoring of SCOM over the process you can easily switch on the email function and be alerted when things went wrong.
This script will:
The parameters you will need to fill in are marked in yellow.
You can download the PowerShell script here.
In this section we are actually defining the location and exporting the management packs:
Define the backup location:
Export the unsealed management packs. With this command we’ll export all the unsealed management packs to the folder. If you (for one reason or another) want to backup all your management packs you can change this code to:
$all_mps = get-managementpack
foreach($mp in $all_mps)
{
export-managementpack -managementpack $mp -path “C:\backups”
}
Thanks to Maarten Goet for providing this example.
Error handling
In this section the script is writing to the Operations manager eventlog a event whether it was successful (id 910) or unsuccessful (ID 911). This can be used to monitor the process.
Feel free to change the ID’s as you please but don’t forget to modify the supplied management pack later on.
The mailing section:
If you choose not to monitor this process with SCOM you can activate the mailing section that warns you about the outcome of the process.
Make sure to change the highlighted sections.
As said before I’m scheduling this script on the RMS using the build-in Windows Task Scheduler.
The command to schedule should be (if you save the file in c:\scripts):
powershell -command “& ‘c:\scripts\backup_mp.ps1’ ”
You can easily monitor the process with SCOM and setup notifications whenever there’s an error. I’ve created a small management pack which contains a monitor to check the status of the backup.
This monitor is healthy by default and comes in critical error when event 911 is logged. However when the next backup is successful, when event 910 is logged, it will return back to healthy. I don’t mind to miss one backup
There’s an automated recovery task included as well to restart the backup when failed.
You can download this small MP here.
Don’t forget to setup your notifications and you’re all done.