Check Exchange Backups

Download the plugin


As any Exchange administrator knows, if your backups aren’t working properly and you don’t use circular logging, you’re going to fill up your disk with transaction logs in addition to being ill-prepared for a disaster. I use this plugin to warn me if, for whatever reason, an Exchange database has not been backed up for a certain number of days.


The config for this is more complex than I would like – if anyone has suggestions for simplifying the plugin’s execution while still capturing the exit code and output, I’m all ears. Right now, I add the plugin to my configuration like this:

[NRPE Handlers] 
check_exchange2007backups = CMD /C ECHO C:\Scripts\Check-Exchange2007Backups.ps1 -w 2 -c 4 -d "CONTOSO-MAIL-01\First Storage Group\Mailbox DB 1" ; exit $LASTEXITCODE | powershell.exe -PSConsoleFile "D:\Program Files\Microsoft\Exchange Server\Bin\ExShell.psc1" -command -

Be careful – that all needs to be on a single line. What’s going on with that command? Well, first we’re launching the Windows command interpreter and telling it to build a long string with the path to the plugin, the arguments, and a second command of “exit $LASTEXITCODE.” This entire string is then piped into a new Powershell instance with the Exchange tools loaded. The Powershell instance runs both commands in sequence and passes the exit code (what Nagios actually uses to determine the check’s state), and the text back to cmd.exe, which passes that output back to NSClient++. You may recognize the syntax of using a hyphen to pass stdin to a command line program from POSIX applications – all this does is tell Powershell to use stdin (which is the command we built before the | symbol) as the argument to use in the -command switch. You should replace the database path with your own database’s path, and the path to the plugin with wherever you choose to keep the file. The -w and -c switches tell the plugin how many days you want to warn and go critical for should Exchange backups be missed. For example, -w 2 -c 4 would enter a warning state if the database has not been backed up for 2 days, and a critical state if it has not been backed up for 4 days. When you are all set up, you should receive output similar to:

OK: Exchange backups are good at 0 day(s) old.

Please leave me feedback with any suggestions or questions should you have them. Thanks for reading!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s