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.

GUI-based point-in-time restore<br />

Chapter 6: Log <strong>Restore</strong>s<br />

It's entirely possible to perform point-in-time restores via the GUI. On the <strong>Restore</strong> Database page, we<br />

simply need to configure a specific date <strong>and</strong> time, in the To a point in time: option, rather than accept<br />

the default setting of most recent possible. We don't provide a full worked example in the GUI, but feel<br />

free to play around with configuring <strong>and</strong> executing these types of restore in the GUI environment.<br />

Don't worry; point-in-time restores are not as complicated as they may sound! To prove<br />

it, let's jump right into the script in Listing 6-3.<br />

The overall intent of this script is to restore the DatabaseForLog<strong>Backup</strong> full backup<br />

file over the top of the DatabaseForLog<strong>Backup</strong>_<strong>Restore</strong>Copy database, created in<br />

the previous GUI restore, apply the entire contents of the first log backup, <strong>and</strong> then the<br />

contents of the second log backup, up to the point just before we inserted 100,000 rows<br />

into MessageTable3.<br />

USE [master]<br />

GO<br />

--STEP 1: <strong>Restore</strong> the full backup. Leave database in restoring state<br />

RESTORE DATABASE [DatabaseForLog<strong>Backup</strong>s_<strong>Restore</strong>Copy]<br />

FROM DISK = N'C:\<strong>SQL</strong><strong>Backup</strong>s\Chapter5\DatabaseForLog<strong>Backup</strong>s_Native_Full.bak'<br />

WITH FILE = 1, MOVE N'DatabaseForLog<strong>Backup</strong>s' TO N'C:\<strong>SQL</strong>Data\<br />

DatabaseForLog<strong>Backup</strong>s_<strong>Restore</strong>Copy.mdf',<br />

MOVE N'DatabaseForLog<strong>Backup</strong>s_log' TO N'C:\<strong>SQL</strong>Data\DatabaseForLog<strong>Backup</strong>s_<br />

<strong>Restore</strong>Copy_1.ldf',<br />

NORECOVERY, STATS = 10<br />

GO<br />

--STEP 2: Completely restore 1st log backup. Leave database in restoring state<br />

RESTORE LOG [DatabaseForLog<strong>Backup</strong>s_<strong>Restore</strong>Copy]<br />

FROM DISK = N'C:\<strong>SQL</strong><strong>Backup</strong>s\Chapter5\DatabaseForLog<strong>Backup</strong>s_Native_Log.trn'<br />

WITH FILE = 1, NORECOVERY, STATS = 10<br />

GO<br />

195

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

Saved successfully!

Ooh no, something went wrong!