Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Difference between .bak & .mdf, .ldf

Author  Topic 

goalie2
Starting Member

3 Posts

Posted - 2009-11-26 : 11:02:31
Folks, what is the difference between the above? I know .bak is a backup file but not sure what the other two are for? Cheers Derek

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2009-11-26 : 11:08:01
.mdf is the primary data file of a SQL database. .ldf is the transaction log file of a SQL database

--
Gail Shaw
SQL Server MVP
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2009-11-26 : 18:04:41
the .bak contains both the mdf and ldf files
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-27 : 01:09:14
quote:
Originally posted by afrika

the .bak contains both the mdf and ldf files



Not quite. The full backup file, which can have an extension of .bak, contains the used portion of the mdf file and enough of the ldf file to make the database consistent when it is restored.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

goalie2
Starting Member

3 Posts

Posted - 2009-11-27 : 03:09:42
Tara, so I shouldn't need to backup the mdf and ldf files aty night only the bak ones?
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2009-11-27 : 04:20:37
ok. tnx 4d info
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2009-11-27 : 05:06:09
quote:
Originally posted by goalie2

Tara, so I shouldn't need to backup the mdf and ldf files aty night only the bak ones?



Correct. You can't really do a file-level backup of the mdf and ldf, as they're locked by SQL Server while it's running. While there are tools that can backup open files, very often if the mdf and ldf are 'backed up' that way, they're not usable afterwards.

Schedule SQL backups (generating a .bak file) regularly. How often depends on how important the data is and when you have maintenance time to do the backups. Also look at log and differential backups if your DB is large or allowable data loss is very small.

Back those backup files to tape/remote storage.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

goalie2
Starting Member

3 Posts

Posted - 2009-11-27 : 05:35:38
Thank you very much Gail for the info. I now know where to start with my backup procedures.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-27 : 12:51:33
We specifically exclude the file backups of all mdf, ldf, and ndf files from our file backup software (Netbackup). On the SQL Server boxes, all we need are the bak, trn, and dif files.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

behrman
Yak Posting Veteran

76 Posts

Posted - 2009-11-28 : 22:26:56
.mdf is extention of primary file,
.ndf is extention of secondary file.

RAQ Report: Web-based Excel-like Java reporting tool
Go to Top of Page
   

- Advertisement -