Database backup


Job details

Name: Database backup
Platform: Sqlserver
Category: Availability
Description: This alert checks if the instance has been restarted since the last check
Long description: This job checks the backup statistics (type D and I) from the msdb.dbo.backupset table (excluding the system databases: master, model and msdb).
Version: 2
Default schedule: 10 6 * *
Requires engine install: No
Compatibility tag: .[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2000′ & hasengine=‘NO’ & (engine_edition = ‘Microsoft SQL Server’ engine_edition = ‘Azure SQL Managed Instance’)]

Parameters

Name Default value Description
ignore_databases 2 The list of databases to be ignored (separated by comma).
warning_threshold 2 The maximum number of hours since the last full database backed.
alarm_threshold 2 The maximum number of hours since the last full database backed.

Job Summary

SELECT msdb.dbo.backupset.database_name, datediff(hour, MAX(msdb.dbo.backupset.backup_finish_date), GETDATE()) as diff_hours, MAX(msdb.dbo.backupset.backup_finish_date) AS last_db_backup_date FROM msdb.dbo.backupset WHERE msdb.dbo.backupset.type in ('D','I') and database_name NOT IN ('master', 'model', 'msdb') GROUP BY msdb.dbo.backupset.database_name ORDER BY diff_hours DESC;

Detailed Monitoring Logic

Output Interpretation

The results are presented in a report format within dbWatch Control Center, with specifics details given for each database. Here are the possible statuses:

Backup Statistics SQL Query
The main SQL query used for extracting backup details:

SELECT msdb.dbo.backupset.database_name, datediff(hour, MAX(msdb.dbo.backupset.backup_finish_date), GETDATE()) as diff_hours, MAX(msdb.dbo.backupset.backup_finish_date) AS last_db_backup_date FROM msdb.dbo.backupset WHERE msdb.dbo.backupset.type in ('D','I') and database_name not in ('master','model','msdb') and database_name IN (SELECT a.name FROM master..sysdatabases a, sys.databases b WHERE a.name=b.name AND convert (varchar(20), DATABASEPROPERTYEX(a.name,'Status'))='ONLINE' AND b.is_read_only !=1) GROUP BY msdb.dbo.backupset.database_name ORDER BY diff_hours DESC

The output from this monitoring job plays a vital role in maintaining the integrity and availability of the database resources managed through dbWatch Control Center.