Friday, September 18, 2020

SQL Server : Find Out the List of Backups taken of Database

Like Restore Audit, we can also find the list of all backup taken, Since SQL Server store the backup history in system tables, using them we can find the information regarding same.

SELECT  bs.database_name
    , bs.backup_start_date
    , bs.compressed_backup_size
    , bs.expiration_date
    , bs.name Backup_Name
    , bs.recovery_model
    , bs.server_name
    , CASE bs.type 
        WHEN 'D' THEN 'Database' 
        WHEN 'L' THEN 'Log' 
        ELSE '[unknown]' END
    , bmf.logical_device_name
    , bmf.physical_device_name
FROM 
msdb.dbo.backupset bs
    INNER JOIN msdb.dbo.backupmediafamily bmf ON bs.media_set_id = bmf.media_set_id
WHERE 
     bs.type = 'D' and
bs.database_name = '**FillDatabaseName**'
ORDER BY 
bs.backup_start_date DESC;
You can copy and paste above query to Query Window and replace "**FillDatabaseName**" string with database name whose backup history need to populate.

No comments:

Post a Comment

web stats