If you want to see the backup history of the selected database or history for all of the databases.
Please use the following script.
SELECT
b.database_name,
m.physical_device_name AS 'Location_Of_Backups',
CAST(CAST(b.backup_size / 1000000 AS INT) AS VARCHAR(14)) AS 'BackupSize_In_MBs',
CAST(DATEDIFF(second, b.backup_start_date, b.backup_finish_date) AS VARCHAR(4)) AS 'Duration_In_Secs',
b.backup_start_date AS'Stareted',
b.backup_finish_date AS'Finished',
CAST(b.first_lsn AS VARCHAR(50)) AS 'First_LSN',
CAST(b.last_lsn AS VARCHAR(50)) AS 'Last_LSN',
CASE b.[type]
WHEN 'D' THEN 'Full Backup'
WHEN 'I' THEN 'Differential Backup'
WHEN 'L' THEN 'Transaction Log Backup'
END AS BackupType,
b.server_name,
b.recovery_model
FROM msdb.dbo.backupset b
INNER JOIN msdb.dbo.backupmediafamily m ON b.media_set_id = m.media_set_id
WHERE b.database_name = DB_NAME() -- For the current database
ORDER BY backup_start_date DESC, backup_finish_date
GO
--
No comments:
Post a Comment