January 16, 2007 at 10:48 pm
Hi,
I can find out what backups were done on a database by quering backupset table:
select * from msdb.dbo.backupset where database_name = 'MyDB'
But how do I find out what is the file name and the path a particular backup used?
Thanks.
January 17, 2007 at 12:24 am
SELECT BS.database_name
, BF.physical_name
FROM msdb.dbo.backupset BS
INNER JOIN msdb.dbo.backupfile BF
ON BF.backup_set_id = BS.backup_set_id
WHERE BS.database_name = 'MyDB'
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
January 17, 2007 at 12:48 am
When you do:
select physical_name from msdb.dbo.backupfile
You get a list of the data and log files like these:
e:\mssql\data\MyDB.mdf
d:\logs\MyDB_log.ldf
What I am looking for is the list of backup files like:
f:\backup\mydb\mydb.bak
f:\backup\mydb\mydb.trn
January 17, 2007 at 12:57 am
Still early on the day
SELECT BS.database_name
, BMF.physical_device_name
, BMF.device_type
FROM msdb.dbo.backupset BS
INNER JOIN msdb.dbo.backupfile BF
ON BF.backup_set_id = BS.backup_set_id
INNER JOIN msdb.dbo.backupmediafamily BMF
on BMF.media_set_id = BS.backup_set_id
WHERE BS.database_name = 'master'
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
January 17, 2007 at 5:45 pm
Unfortunately this query does not work correctly on any of my servers SQL 2000 or 7.0: the database name gets linked to backups for different databases. Is there a chance that "BMF.media_set_id = BS.backup_set_id" join is not quite correct?
January 18, 2007 at 12:28 am
SELECT b.database_name,
b.backup_start_date,
b.backup_finish_date,
b.user_name,
f.logical_name,
f.physical_name,
mf.physical_device_name,
f.file_type,
f.file_size,
b.backup_size
FROM msdb.dbo.backupfile f,
msdb.dbo.backupset b,
msdb.dbo.backupmediafamily mf
WHERE f.backup_set_id = b.backup_set_id
AND b.media_set_id = mf.media_set_id
AND b.database_name = 'pubs'
ORDER BY b.backup_start_date DESC
MohammedU
Microsoft SQL Server MVP
January 18, 2007 at 1:12 am
making this #é&() mistakes, you can immagine the rest of my day
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
January 18, 2007 at 2:52 am
Here is the solution:
select
filename from sysfiles
that wil give you something like this :
F
:\MSSQL\MSSQL\data\DEVDAT.mdf
K
:\MSSQL.1\MSSQL\Log\DEVDAT_log.ldf
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply