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 10: Partial <strong>Backup</strong> <strong>and</strong> <strong>Restore</strong><br />

Performing Partial Database <strong>Restore</strong>s<br />

We will be performing two restore examples: one restoring the DatabaseForPartial-<br />

<strong>Backup</strong>s database to the state in which it existed after the third data load, using the full<br />

database <strong>and</strong> full partial backup files, <strong>and</strong> one restoring the database to its state after the<br />

fourth data load, using the full database, full partial, <strong>and</strong> differential partial backup files.<br />

Restoring a full partial backup<br />

Listing 10-8 show the two simple steps in our restore process. The first step restores our<br />

full database backup file, which will restore the data <strong>and</strong> objects in both our read-write<br />

<strong>and</strong> read-only filegroups. In this step, we include the NORECOVERY option, so that <strong>SQL</strong><br />

<strong>Server</strong> leaves the database in a state where we can apply more files. This is important<br />

so that we don't wind up with a database that is online <strong>and</strong> usable before we apply the<br />

partial backup.<br />

The second step restores our full partial backup file. This will overwrite the read-write<br />

files in the existing database with the data from the backup file, which will contain all the<br />

data we inserted into the primary data file, up to <strong>and</strong> including the third data load. We<br />

specify that this restore operation be completed with RECOVERY.<br />

USE [master]<br />

GO<br />

RESTORE DATABASE [DatabaseForPartial<strong>Backup</strong>s]<br />

FROM DISK = N'C:\<strong>SQL</strong><strong>Backup</strong>s\Chapter10\DatabaseForPartial<strong>Backup</strong>s_FULL.bak'<br />

WITH NORECOVERY<br />

GO<br />

RESTORE DATABASE [DatabaseForPartial<strong>Backup</strong>s]<br />

FROM DISK = N'C:\<strong>SQL</strong><strong>Backup</strong>s\Chapter10\DatabaseForPartial<strong>Backup</strong>s_PARTIAL_Full.bak'<br />

WITH RECOVERY<br />

GO<br />

Listing 10-8: Restoring the partial full database backup.<br />

357

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

Saved successfully!

Ooh no, something went wrong!