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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 1: Basics of <strong>Backup</strong> <strong>and</strong> <strong>Restore</strong><br />

details of a specific action within the database (for example, starting a transaction, or<br />

inserting a row, or modifying a row, <strong>and</strong> so on). Every log record will record the identity<br />

of the transaction that performed the change, which pages were changed, <strong>and</strong> the data<br />

changes that were made. Certain log records will record additional information. For<br />

example, the log record recording the start of a new transaction (the LOP_BEGIN_XACT<br />

log record) will contain the time the transaction started, <strong>and</strong> the LOP_COMMIT_XACT<br />

(or LOP_ABORT_XACT) log records will record the time the transaction was committed<br />

(or aborted).<br />

From the point of view of <strong>SQL</strong> <strong>Server</strong> <strong>and</strong> the DBA looking after it, the transaction log<br />

performs the following critical functions:<br />

• ensures transactional durability <strong>and</strong> consistency<br />

• enables, via log backups, point-in-time restore of databases.<br />

Transactional durability <strong>and</strong> consistency<br />

Via a Write Ahead Logging (WAL) mechanism that ensures that change descriptions are<br />

written to the transaction log before the actual data changes are written to the data files,<br />

<strong>SQL</strong> <strong>Server</strong> guarantees that all valid, committed data will be written to the data files <strong>and</strong><br />

that the effects of any partial, uncommitted transactions, in the data file, can be "undone,"<br />

via transaction rollback.<br />

As noted previously, the database's log file provides a record of all transactions performed<br />

against that database. When a data modification is made, the relevant data pages are read<br />

from the data cache, first being retrieved from disk if they are not already in the cache.<br />

Data is modified in the data cache, <strong>and</strong> the log records describing the effects of the transaction<br />

are created in the log cache. Any page in the cache that has been modified since<br />

being read from disk is called a "dirty" page. When a periodic CHECKPOINT operation<br />

occurs, all dirty pages, regardless of whether they relate to committed or uncommitted<br />

transactions, are flushed to disk. The WAL protocol dictates that, before a data page is<br />

25

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

Saved successfully!

Ooh no, something went wrong!