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 8: Database <strong>Backup</strong> <strong>and</strong> <strong>Restore</strong> with <strong>SQL</strong> <strong>Backup</strong> Pro<br />

• ErrorCode is the <strong>SQL</strong> <strong>Server</strong> return value. A value above 0 is returned only when <strong>SQL</strong><br />

<strong>Server</strong> itself runs into an issue. Having an error code returned from <strong>SQL</strong> <strong>Server</strong> almost<br />

always guarantees a critical error for the entire operation.<br />

We test the value of each of these codes <strong>and</strong>, if a serious problem has occurred, we raise<br />

an error to <strong>SQL</strong> <strong>Server</strong> so that, if this were run in a <strong>SQL</strong> <strong>Server</strong> Agent job, it would<br />

guarantee to fail <strong>and</strong> alert someone, if the job were configured to do so. We do have it<br />

set up to send email from <strong>SQL</strong> <strong>Backup</strong> on a failure, but also having the <strong>SQL</strong> Agent job<br />

alert on failure is a nice safeguard to have in place. What we do in this section is totally<br />

customizable <strong>and</strong> dictated by our needs.<br />

Restoring Database <strong>Backup</strong>s with <strong>SQL</strong><br />

<strong>Backup</strong> Pro<br />

Having performed our range of full, log <strong>and</strong> differential backups, using <strong>SQL</strong> <strong>Backup</strong>, it's<br />

time to demonstrate several useful restore examples, namely:<br />

• restoring to the end of a given transaction log<br />

• a complete restore, including restores of the tail log backup<br />

• a restore to a particular point in time within a transaction log file.<br />

Preparing for restore<br />

In order to prepare for our restore operations, we're going to add a few new rows to<br />

MessageTable1, perform a log backup, <strong>and</strong> then add a few new rows to MessageTable2,<br />

as shown in Listing 8-10.<br />

267

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

Saved successfully!

Ooh no, something went wrong!