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 />

So, at this stage, we've captured a full backup of our new database, containing three<br />

tables, each with ten rows of data. We're ready to start taking log backups now, but<br />

let's run the DBCC <strong>SQL</strong>PERF(LOGSPACE) comm<strong>and</strong> again, <strong>and</strong> see what happened to<br />

our log space.<br />

<strong>Backup</strong> Stage Log Size Space Used<br />

Before full backup 50 MB 0.65 %<br />

After full backup 50 MB 0.73%<br />

Figure 5-3: DBCC <strong>SQL</strong>PERF (LOGSPACE) output after full backup.<br />

What's actually happened here isn't immediately apparent from these figures, so it needs a<br />

little explanation. We've discussed earlier how, for a FULL recovery model database, only<br />

a log backup can free up log space for reuse. This is true, but the point to remember is<br />

that such a database is actually operating in auto-truncate mode until the first full backup<br />

of that database completes. The log is truncated as a result of this first-ever full backup<br />

<strong>and</strong>, from that point on, the database is truly in FULL recovery, <strong>and</strong> a full backup will<br />

never cause log truncation. So, hidden in our figures is the fact that the log was truncated<br />

as a result of our first full backup, <strong>and</strong> the any space taken up by the rows we added was<br />

made available for reuse. Some space in the log would have been required to record the<br />

fact that a full backup took place, but overall the space used shows very little change.<br />

Later in the chapter, when taking log backups with T-<strong>SQL</strong>, we'll track what happens to<br />

these log space statistics as we load a large amount of data into our tables, <strong>and</strong> then take a<br />

subsequent log backup.<br />

160

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

Saved successfully!

Ooh no, something went wrong!