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 9: File <strong>and</strong> Filegroup <strong>Backup</strong> <strong>and</strong> <strong>Restore</strong><br />

Figure 9-5: Required backups for our complete restore of DatabaseForFile<strong>Backup</strong>s.<br />

The first step is to capture that tail log backup, <strong>and</strong> prepare for the restore process, as<br />

shown in Listing 9-18.<br />

USE master<br />

GO<br />

--backup the tail<br />

BACKUP LOG [DatabaseForFile<strong>Backup</strong>s]<br />

TO DISK = N'C:\<strong>SQL</strong><strong>Backup</strong>s\Chapter9\DatabaseForFile<strong>Backup</strong>s_TLOG_TAIL.trn'<br />

WITH NORECOVERY<br />

GO<br />

Listing 9-18: Tail log backup.<br />

Notice the use of the NORECOVERY option in a backup; this lets <strong>SQL</strong> <strong>Server</strong> know that we<br />

want to back up the transactions in the log file <strong>and</strong> immediately place the database into a<br />

restoring state. This way, no further transactions can slip past us into the log while we are<br />

preparing the RESTORE comm<strong>and</strong>.<br />

We're now ready to start the restore process. The first step is to restore the two full<br />

file backups. We're going to restore over the top of the existing database, as shown<br />

in Listing 9-19.<br />

322

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

Saved successfully!

Ooh no, something went wrong!