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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 9: File <strong>and</strong> Filegroup <strong>Backup</strong> <strong>and</strong> <strong>Restore</strong><br />

<strong>SQL</strong> <strong>Backup</strong> file backups<br />

Let's take a quick look at how to capture both types of file backup, full <strong>and</strong> differential,<br />

via the Red Gate <strong>SQL</strong> <strong>Backup</strong> tool. I assume basic familiarity with the tool, based on the<br />

coverage provided in the previous chapter, <strong>and</strong> so focus only on aspects of the process<br />

that are different from what has gone before, with database backups. We're going to take<br />

a look at file backups using <strong>SQL</strong> <strong>Backup</strong> scripts only, <strong>and</strong> not via the <strong>SQL</strong> <strong>Backup</strong> GUI.<br />

There are a couple of reasons for this:<br />

• the version of <strong>SQL</strong> <strong>Backup</strong> (6.4) that was used in this book did not support differential<br />

file backups via the GUI<br />

• assuming that, if you worked through Chapter 8, you are now comfortable using the<br />

basic <strong>SQL</strong> <strong>Backup</strong> functionality, so you don't need to see both methods.<br />

To get started, we'll need a new sample database on which to work. We can simply<br />

adapt the database creation script in Listing 9-6 to create a new, identically-structured<br />

database, called DatabaseForFile<strong>Backup</strong>_SB <strong>and</strong> then use Listing 9-7 to create the<br />

tables <strong>and</strong> insert the initial row. Alternatively, the script to create the database <strong>and</strong> tables,<br />

<strong>and</strong> insert the initial data, is provided ready-made (DatabaseForFile<strong>Backup</strong>_SB.sql) in<br />

code download for this book, at http://www.simple-talk.com/RedGateBooks/<br />

ShawnMcGehee/<strong>SQL</strong><strong>Server</strong><strong>Backup</strong>And<strong>Restore</strong>_Code.zip.<br />

<strong>SQL</strong> <strong>Backup</strong> full file backups<br />

Having created the sample database <strong>and</strong> tables, <strong>and</strong> loaded some initial data, let's jump<br />

straight in <strong>and</strong> take a look at the script to perform full file backups of both the PRIMARY<br />

<strong>and</strong> SECONDARY data files, as shown in Listing 9-12.<br />

314

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

Saved successfully!

Ooh no, something went wrong!