Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Large ldf file in SQL Server

Posted on 2009-05-19
7
332 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 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24419708
>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
ID: 24419740
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
ID: 24419762
BTW should I check the 'auto shrink' option?
db-properties.bmp
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 24419775
>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 143

Expert Comment

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

Author Comment

by:hmcgeehan
ID: 24420178
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 143

Expert Comment

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

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
t-sql need help on t-sql 10 25
VB.net Duplicating a table - primary key not created 3 31
Query for timesheet application 3 17
SQL - Simple Pivot query 8 13
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

856 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