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.

Restoring Databases<br />

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

Of course, the ultimate goal of our entire <strong>SQL</strong> <strong>Server</strong> backup strategy is to prepare<br />

ourselves for the, hopefully rare, cases where we need to respond quickly to an emergency<br />

situation, for example restoring a database over one that has been damaged, or creating<br />

a second copy of a database (see http://msdn.microsoft.com/en-us/library/ms190436.<br />

aspx) in order to retrieve some data that was accidentally lost from that database. In<br />

non-emergency scenarios, we may simply want to restore a copy of a database to a<br />

development or test server.<br />

For a user database operating in FULL recovery model, we have the widest range of<br />

restore options available to us. As noted throughout the chapter, we can take transaction<br />

log backups <strong>and</strong> use them, in conjunction with full <strong>and</strong> differential backups, to restore a<br />

database to a specific point within a log file. In fact, the RESTORE LOG comm<strong>and</strong> supports<br />

several different ways to do this. We can:<br />

• recover to a specific point in time – we can stop the recovery at a specific point in time<br />

within a log backup file, recovering the database to the point it was in when the last<br />

transaction committed, before the specified STOPAT time<br />

• recover to a marked transaction – if a log backup file contains a marked transaction<br />

(defined using BEGIN TRAN TransactionName WITH MARK 'Description…')<br />

then we can recover the database to the point that this transaction starts (STOPBE-<br />

FOREMARK) or completes (STOPATMARK)<br />

• recover to a Log Sequence Number – stop the recovery at a specific log record,<br />

identified by its LSN (see Chapter 6, Log <strong>Restore</strong>s).<br />

We'll cover several examples of the first option (which is by far the most common) in this<br />

book. In addition, we can perform more "granular" restores. For example, in certain cases,<br />

we can recover a database by restoring only a single data file (plus transaction logs), rather<br />

than the whole database. We'll cover these options in Chapters 9 <strong>and</strong> 10.<br />

46

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

Saved successfully!

Ooh no, something went wrong!