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 />

Preparing for partial backups<br />

Listing 10-1 shows the script to create a DatabaseForPartial<strong>Backup</strong>s database with<br />

multiple data files. The primary data file will hold our read-write data, <strong>and</strong> a secondary<br />

data file, in a filegroup called Archive, will hold our read-only data. Having created the<br />

database, we immediately alter it to use the SIMPLE recovery model.<br />

USE [master]<br />

GO<br />

CREATE DATABASE [DatabaseForPartial<strong>Backup</strong>s] ON PRIMARY<br />

( NAME = N'DatabaseForPartial<strong>Backup</strong>s'<br />

, FILENAME = N'C:\<strong>SQL</strong>Data\DatabaseForPartial<strong>Backup</strong>s.mdf'<br />

, SIZE = 10240KB , FILEGROWTH = 10240KB ), FILEGROUP [Archive]<br />

( NAME = N'DatabaseForPartial<strong>Backup</strong>s_ReadOnly'<br />

, FILENAME = N'C:\<strong>SQL</strong>Data\DatabaseForPartial<strong>Backup</strong>s_ReadOnly.ndf'<br />

, SIZE = 10240KB , FILEGROWTH = 10240KB ) LOG ON<br />

( NAME = N'DatabaseForPartial<strong>Backup</strong>s_log'<br />

, FILENAME = N'C:\<strong>SQL</strong>Data\DatabaseForPartial<strong>Backup</strong>s_log.ldf'<br />

, SIZE = 10240KB , FILEGROWTH = 10240KB )<br />

GO<br />

ALTER DATABASE [DatabaseForPartial<strong>Backup</strong>s] SET RECOVERY SIMPLE<br />

GO<br />

Listing 10-1: Creating the DatabaseForPartial<strong>Backup</strong>s test database.<br />

The script is fairly straightforward <strong>and</strong> there is nothing here that we haven't discussed in<br />

previous scripts for multiple data file databases. The Archive filegroup will eventually be<br />

set to read-only, but first we are going to need to create some tables in this filegroup <strong>and</strong><br />

populate one of them with data, as shown in Listing 10-2.<br />

351

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

Saved successfully!

Ooh no, something went wrong!