Check SQL last back-date

  • September 29, 2017
  • 0 Comments

If you want to check in SQL when your databases was last back-upped (+ the type of back-up), you can execute the script below. this will list you everything of the last 7 days.

SELECT 
CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server, 
msdb.dbo.backupset.database_name, 
msdb.dbo.backupset.backup_start_date, 
msdb.dbo.backupset.backup_finish_date, 
msdb.dbo.backupset.expiration_date, 
CASE msdb..backupset.type 
WHEN 'D' THEN 'Database' 
WHEN 'I' THEN 'Differential database' 
WHEN 'L' THEN 'Log' 
WHEN 'F' THEN 'File/Group' 
WHEN 'G' THEN 'Differential file' 
WHEN 'P' THEN 'Partial' 
WHEN 'Q' THEN 'Differential partial' 
END AS backup_type, 
msdb.dbo.backupset.backup_size, 
msdb.dbo.backupmediafamily.logical_device_name, 
msdb.dbo.backupmediafamily.physical_device_name, 
msdb.dbo.backupset.name AS backupset_name, 
msdb.dbo.backupset.description 
FROM msdb.dbo.backupmediafamily 
INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id 
WHERE (CONVERT(datetime, msdb.dbo.backupset.backup_start_date, 102) >= GETDATE() - 7) 
ORDER BY 
msdb.dbo.backupset.backup_finish_date desc,
msdb.dbo.backupset.database_name