SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Backup History

Can you tell me the drive we were backing up server #58 to exactly 8 months ago, and, if possible, it would really help if you could give me the exact file name for me to pull the backup from tape for you.  Or, last night’s backup didn’t finish until after the tapes started, did those backups always take that long and is it taking longer because the databases are actually growing that much?

The answer to those questions tends to be “Ok, no problem.”

SELECT TOP 100 bs.database_name
    , bs.backup_start_date
    , bs.backup_finish_date
    , backup_duration_minutes = (DateDiff(second, backup_start_date, backup_finish_date)+30)/60
    , backup_duration_seconds = DateDiff(second, backup_start_date, backup_finish_date)
    , backup_size_mb = Cast(bs.backup_size / 1024 / 1024 as Int)
    --, compressed_backup_size_mb = Cast(bs.compressed_backup_size / 1024 / 1024 as Int) --SQL 2008+ only
    , backup_type = CASE bs.type 
                        WHEN 'D' THEN 'FULL' 
                        WHEN 'I' THEN 'Diff' 
                        WHEN 'L' THEN 'Log' 
                        ELSE 'UNKNOWN' 
    , bmf.physical_device_name
FROM msdb..backupset bs
    INNER JOIN msdb..backupmediafamily bmf ON bs.media_set_id = bmf.media_set_id
--WHERE bs.database_name like 'msdb'
    --AND bs.type <> 'L'
    --AND backup_start_date BETWEEN '2013-05-13 00:00' AND '2013-05-13 08:00'
ORDER BY Backup_Start_Date DESC

It’s common in my scripts for me to put 10 things in the where clause and comment them out. My problem is that I don’t want to look around for field names to filter my scripts, but I don’t always want to filter my scripts the same way. It works for me, and you’ll either get used to it or rewrite it for your own use.

Filed under: Backups, Scripts, SQL Server Tagged: backup, File, recovery

Simple SQL Server

I started out working with Microsoft Access and SQL Server back in 2000 as the only employee doing IT full-time, and worked most of my career where “big fish in a little pond” was an overstatement. Learning is scarce when you do everything and don’t work with anyone who knows more than you. In 2010 I was plunged into the Ocean and grabbed onto anything I could find to stay afloat. I wasn’t going to simply run scripts I didn’t understand, so I learned the DMVs and system tables in the scripts I found and rewrote them all. Now, I know enough where I can start giving back to a community that saved me from drowning.


Leave a comment on the original post [simplesqlserver.com, opens in a new window]

Loading comments...