17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

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 8: Backup and Restore for <strong>FILESTREAM</strong> Databases<strong>The</strong> first step is to restore the full backup to create the NorthPole2 database, as shownin Listing 8-7. Notice the use <strong>of</strong> the NORECOVERY option; this instructs <strong>SQL</strong> <strong>Server</strong> toleave the database in a restoring state, ready to receive more backup files.-- Restore the full backupRESTORE DATABASE NorthPole2FROM DISK = 'C:\<strong>Art</strong>OfFS\Demos\Chapter8\bak\NorthPole.bak'WITH NORECOVERY,MOVE 'NorthPole' TO 'C:\<strong>Art</strong>OfFS\Demos\Chapter8\NorthPole2.mdf',MOVE 'NorthPole_log' TO 'C:\<strong>Art</strong>OfFS\Demos\Chapter8\NorthPole2_log.ldf',MOVE 'NorthPole_fs' TO 'C:\<strong>Art</strong>OfFS\Demos\Chapter8\NorthPole2_fs',GOListing 8-7:Restoring a full backup.<strong>The</strong> code uses the MOVE option three times, to specify the location <strong>of</strong> the data file,log file, and <strong>FILESTREAM</strong> data container, respectively. Note that the leaf-level folder(NorthPole2_fs in this example) should not exist already, but the containing folder(C:\<strong>Art</strong>OfFS\Demos\Chapter8) must exist! <strong>SQL</strong> <strong>Server</strong> reserves the "exclusive" rightsto create and configure NorthPole2_fs folder as part <strong>of</strong> the restore operation.<strong>The</strong> next step is to completely restore the first transaction log backup, again leaving theNorthPole2 database in a restoring state.RESTORE LOG NorthPole2FROM DISK = 'C:\<strong>Art</strong>OfFS\Demos\Chapter8\bak\NorthPole_log.trn'WITH NORECOVERYListing 8-8:Restoring the transaction log backup.<strong>The</strong> final step is the interesting one; we apply the second log backup, but stop the restoreat the point just before the data was accidentally deleted, and then recover the database.If you are following this example on your own system, insert the date and time fromListing 8-9.321

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

Saved successfully!

Ooh no, something went wrong!