What It Does
The script finds local SQL Server instances and connects to each running one with Windows authentication through .NET, without the SqlServer module. It reads msdb backup history for online databases other than tempdb and database snapshots, and reports stopped instances as unchecked.
It alerts on old full backups and on missing full backups once the database reaches MaxFullHours of age. It checks for missing or old log backups on FULL or BULK_LOGGED databases that already have a full backup, apart from read-only databases and the model database. Copy-only backups do not count.
Backups taken by a tool that does not record them in msdb, such as some image-level backups, are invisible here, so pair it with that tool's own report. When no instance is running it ends with an error rather than a false OK.
It connects as the account that runs it, normally SYSTEM from your RMM. If SQL Server refuses that login, the run ends with SQL Server's own message and the account name, so you know which login to create.
Before You Run It
- Run it on the SQL Server itself, as SYSTEM from your RMM.
- Make sure SYSTEM (or the run account) has a SQL Server login with read access to msdb and VIEW ANY DATABASE; newer installs may not grant it.
- Set MaxFullHours and MaxLogHours to match the backup schedule, with a little slack.
Type and Risk
- Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
- Risk: Low. It reads and changes nothing.
- Restart: It never restarts the machine.
- Typical run: Under 30 seconds.
- Example answer: "2 database(s) with backup problems: SQL01 Sales FULL backup 41 h old; SQL01 Orders no LOG backup within 4 h"
- Tested before listing on a Windows Server 2025 domain controller (VM) with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.
Inputs
Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.
- MaxFullHours: Alert when the last FULL backup is older than this many hours. Whole number, 1 to 8760. Default 26 (a nightly backup plus two hours).
- MaxLogHours: Alert when a FULL or BULK_LOGGED recovery database has no LOG backup within this many hours. Whole number, 1 to 8760. Default 4.
- ExcludeDatabases: Exact database names to leave out, separated by commas or semicolons. No wildcards. Default empty.
Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.