chapter twenty five

25 dbachecks

 

Imagine that you want to easily check if all your databases have at least one FULL database backup in the last 24 hours. Or, that databases' integrity checks have been performed, with success, at least in the last 7 days and data corruption does not exist. Wouldn’t it be great if we could see it in the console with green/red messages or even on a nice Power BI dashboard?

If you never heard about dbachecks, it is a open source PowerShell module which was created by and for SQL Server pros who need to validate their environments. With dbachecks we enable crowd-source checklists using Pester tests.

25.1 What dbachecks and dbatools have in common

You may be wondering why we are talking about dbachecks, which is a different PowerShell module, here in a book on the dbatools module.

The reason is that dbachecks relies on dbatools commands to get values from all different configurations and/or properties, and uses the Pester - Testing framework PowerShell module to run unit tests and, therefore, check if the result is the one we want or not.

Pester makes it possible to create our own tests for PowerShell. Cláudio likes to say - "If you can PowerShell it, you can Pester it". Before we have created the dbachecks PowerShell module each person had their own Pester tests written in different manners but to achieve the same outcome. With dbachecks we made it possible to share these tests with everyone in a central repository.

25.2 Do I have recent full backups?

25.3 Configure the check parameters

25.4 Data → Database

25.4.1 Store data

25.4.2 Power BI dashboard

25.4.3 Configure the connection

25.5 Hands-on Lab