Retreiving Backup file details in SQL Server

Sometimes we want to view the information of a backup file that was taken earlier. Below query returns the records of all the backup files that are older than 30 days.

    CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server
  , B.database_name
  , B.backup_start_date
  , B.backup_finish_date
  , B.user_name
  , CASE B.type
      WHEN 'D' THEN 'Database'
      WHEN 'L' THEN 'Log'
      WHEN 'I' THEN 'Differential database'
      WHEN 'F' THEN 'File or filegroup'
      WHEN 'G' THEN 'Differential file'
      WHEN 'P' THEN 'Partial'
      WHEN 'Q' THEN 'Differential partial'
    END AS backup_type
  , B.server_name 
  , B.machine_name 
  , B.backup_size
  , A.physical_device_name
  , AS backupset_name
FROM msdb.dbo.backupmediafamily A
JOIN msdb.dbo.backupset B 
  ON A.media_set_id = B.media_set_id
WHERE (CONVERT(datetime, B.backup_start_date, 102) >= GETDATE() - 7)
B.backup_finish_date DESC
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

  • Recent Posts

    • 450,726 hits
  • Join 37 other followers

  • Archives

  • Categories

  • April 2011
    M T W T F S S
    « Mar   May »
  • Advertisements
%d bloggers like this: