So I’ve been pretty bad about blogging lately. I don’t buy in much to excuses and so I have none to offer. Just got away from me (something I’ll talk about shortly when I review my 2012 goals). Anyway, let’s talk about something a little more useful to you, the reader.
A couple weeks ago, I gave a short presentation on MSDB’s BackupSet. It was a fun little presentation and gave me a chance to share with the Boulder SQL user group one of my favorite tables. Why one of my favorites? Simply because there’s so much useful information packed in there, particularly when it comes to the critical job of monitoring your backups. If you haven’t looked at it, I highly recommend that you check it out.
While developing the presentation, I put together a handy query that I wanted to share. It’s very useful for not only showing you when your latest backups were, but also the size and location of those backups:
select bs.database_name ,bs.backup_finish_date ,bs.backup_size/1024.0/1024.0 [backup_size_mb] ,bs.compressed_backup_size/1024.0/1024.0 [compressed_size_mb] ,datediff(ss,backup_start_date,backup_finish_date) [backup_time] ,((bs.backup_size/1024.0/1024.0)/(datediff(ss,backup_start_date,backup_finish_date)+1)) [mb_per_second] ,1.0-(bs.compressed_backup_size*1.0/bs.backup_size) [compression_ratio] ,bm.physical_device_name from msdb.dbo.backupset bs join msdb.dbo.backupmediafamily bm on (bs.media_set_id = bm.media_set_id) join (select database_name ,max(backup_finish_date) last_backup from msdb.dbo.backupset where type = 'D' group by database_name) lb on (bs.database_name = lb.database_name and bs.backup_finish_date = lb.last_backup) where type = 'D'