The Surly Admin

Father, husband, IT Pro, cancer survivor

SQL Backup File Name

As I’ve mentioned, I’m doing a ton of SQL work lately (more on that later!) and I just had a co-worker ask for something so I threw together this quick query.  One of our backups had failed and he just wanted to know where the backup file was being placed (in most cases we backup locally but we do have some exceptions).  I threw together this query to locate the file name:


SELECT bs.database_name AS Name,
bs.backup_finish_date AS LastBackup,
bmf.physical_device_name AS BackupFile
FROM msdb.dbo.backupmediafamily AS bmf
JOIN msdb.dbo.backupset AS bs
ON bmf.media_set_id = bs.media_set_id
WHERE bs.type = 'D'
ORDER BY bs.backup_finish_date DESC

I also have a new PowerShell script that reports on SQL backups that I want to get published, as well as a more intelligent index rebuilder that is Availability Group and log shipping aware.

Stay tuned!

Advertisement

May 11, 2015 - Posted by | MS SQL, PowerShell | ,

No comments yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: