Through SINGLE T-sql query can we find : 1. Database Backup mode - [full,simple,bulk] 2. IS database is scheduled for backup [yes, no] 3. If backup is enabled the size of the DB backup
and Daily transaction log backup size ? any help
Through SINGLE T-sql query can we find : 1. Database Backup mode - [full,simple,bulk] 2. IS database is scheduled for backup [yes, no] 3. If backup is enabled the size of the DB backup
and Daily transaction log backup size ? any help
You can query the msdb backupset table for this kind of information:
SELECT
database_name,
recovery_model,
CASE bs.type
WHEN 'D' THEN 'FULL'
WHEN 'I' THEN 'DIFFERENTIAL'
WHEN 'L' THEN 'TRANSACTION LOG'
ELSE 'UNKNOWN'
END AS backup_type,
backup_finish_date,
backup_size,
compressed_backup_size
FROM msdb.dbo.backupset bs
EDIT:
This query will return the database name, recovery model, and the last datetime for full, differential, and log backups. If a database returns NULL for the last FULL it is not being backed up at all. If it returns NULL for the last transaction log and the database uses FULL recovery it is not being backed up correctly.
SELECT
d.name,
d.recovery_model_desc,
MAX(CASE bs.type WHEN 'D' THEN backup_finish_date ELSE NULL END) AS [last_full_backup_date],
MAX(CASE bs.type WHEN 'I' THEN backup_finish_date ELSE NULL END) AS [last_diff_backup_date],
MAX(CASE bs.type WHEN 'L' THEN backup_finish_date ELSE NULL END) AS [last_tlog_backup_date]
FROM sys.databases d
LEFT JOIN msdb.dbo.backupset bs ON bs.database_name = d.name
GROUP BY d.name, d.recovery_model_desc