Solved

Large ldf file in SQL Server

Posted on 2009-05-19
7
327 Views
Last Modified: 2013-05-21
Hi

In SQL Server 2000 we have an intranet database (which uses sharepoint) and the .ldf file is now over 50GB and the .mdf file is over 7GB.

The backup runs every night.
It's Recovery Model 'Full'

Is there anything I can do to make the files smaller?

I've seen advice to truncate the database with this command
"backup log dbname with truncate_only"

Any ideas?

Thanks
0
Comment
Question by:hmcgeehan
  • 4
  • 3
7 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>It's Recovery Model 'Full'
you don't see to be running NO transaction log backup, which means the log space in the .ldf file never get's reclaimable.

>I've seen advice to truncate the database with this command
don't. at least not regularly.
just implement regular transaction log backups (the first one will be big!), and once that is in place, you can try to shrink the .ldf file to a reasonable size.
0
 

Author Comment

by:hmcgeehan
Comment Utility
Thanks!

So what do I need to do from here?
Implement a transaction log backup?
How do I do that?
Do I do it instead of a full backup?

My hard disk space is at a minimum now.
Less than 1GB left!

Thanks
0
 

Author Comment

by:hmcgeehan
Comment Utility
BTW should I check the 'auto shrink' option?
db-properties.bmp
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
Comment Utility
>Do I do it instead of a full backup?
no, in addition to the full backup.

you have to be aware why you do backups: it's to be able to restore.
with a full backup (only), you can only restore that one. all changes made since that full backup are lost.
there is where the transaction log backup comes into the play: with those backups, you can restore the database to ANY point in time from the full backup to the last transaction in the transaction log backups.

note: you must have ALL the transaction log backup since the full backup to the time you want to restore!


>My hard disk space is at a minimum now. >Less than 1GB left!

ok, do this:



backup log dbname with truncate_only;

checkpoint;

dbcc shrinkfile (your_log_file.ldf, truncate_only);

-- http://msdn.microsoft.com/en-us/library/ms189493.aspx --
 
 

you might need to repeat this, the shrink might not "work" on the first time.

once this freed up your disk space, run 1 full backup, and implement the transaction log backup ASAP

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>BTW should I check the 'auto shrink' option?
NO. that will just waste I/O ....
0
 

Author Comment

by:hmcgeehan
Comment Utility
Thanks

As this is a sharepoint database would we need to disable the website to ensure no attempts are made to update the database while we're doing the backup and shrink?

Thanks
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
no. these operation can be done online.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now