30.06.2013 Views

SQL Server Backup and Restore - Simple Talk

SQL Server Backup and Restore - Simple Talk

SQL Server Backup and Restore - Simple Talk

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5: Log <strong>Backup</strong>s<br />

As a log file grows <strong>and</strong> grows, a related problem is that the log can become "internally<br />

fragmented," if the growth occurs in lots of small increments. This can affect the performance<br />

of any operation that needs to read the transaction log (such as database restores).<br />

Failure to take log backups<br />

Still the most common cause of a rapidly growing log, sadly, is simple mismanagement;<br />

in other words failure to take log backups for a database operating in FULL recovery.<br />

Since log backups are the only operation that truncates the log, if they aren't performed<br />

regularly then your log file may grow rapidly <strong>and</strong> eat up most or all of the space on your<br />

drive. I rest more peacefully at night in the knowledge that, having read this chapter, this<br />

is a trap that won't catch you out.<br />

If you're asked to troubleshoot a "runaway" transaction log for a FULL recovery model<br />

database, then a useful first step is to interrogate the value of the log_reuse_wait_<br />

desc column in sys.databases, as shown in Listing 5-9.<br />

USE master<br />

GO<br />

SELECT name ,<br />

recovery_model_desc ,<br />

log_reuse_wait_desc<br />

FROM sys.databases<br />

WHERE name = 'MyDatabase'<br />

Listing 5-9: Finding possible causes of log growth.<br />

If the value returned for the log_reuse_wait_desc column is LOG BACKUP, then the<br />

reason for the log growth is the lack of a log backup. If this database requires log backups,<br />

start taking them, at a frequency that will satisfy the terms of the SLA, <strong>and</strong> control the<br />

growth of the log from here in. If the database doesn't require point-in-time recovery,<br />

switch the database to SIMPLE recovery.<br />

173

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!