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

-- differential partial backup with <strong>SQL</strong> <strong>Backup</strong><br />

EXECUTE master..sqlbackup '-<strong>SQL</strong> "BACKUP DATABASE [DatabaseForPartial<strong>Backup</strong>s]<br />

READ_WRITE_FILEGROUPS<br />

TO DISK = ''C:\<strong>SQL</strong><strong>Backup</strong>s\Chapter10\DatabaseForPartial<strong>Backup</strong>s_Partial_Diff.sqb''<br />

WITH DIFFERENTIAL, DISKRETRYINTERVAL = 30, DISKRETRYCOUNT = 10, COMPRESSION = 3,<br />

THREADCOUNT = 2"'<br />

Listing 10-13: A <strong>SQL</strong> <strong>Backup</strong> script for full partial <strong>and</strong> differential partial backups.<br />

The comm<strong>and</strong>s are very similar to the native comm<strong>and</strong>s, <strong>and</strong> nearly identical to the<br />

<strong>SQL</strong> <strong>Backup</strong> comm<strong>and</strong>s we have used in previous chapters. The only addition is the<br />

same new option we saw in the native comm<strong>and</strong>s earlier in this chapter, namely<br />

READ_WRITE_FILEGROUPS.<br />

Listing 10-14 shows the equivalent restore comm<strong>and</strong>s for partial backups; again, they are<br />

very similar to what we have seen before in other restore scripts. We restore the last full<br />

database backup leaving the database ready to process more files. This will restore all of<br />

the read-only data, <strong>and</strong> leave the database in a restoring state, ready to apply the partial<br />

backup data. We then apply the full partial <strong>and</strong> differential partial backups, <strong>and</strong> recover<br />

the database.<br />

-- full database backup restore<br />

EXECUTE master..sqlbackup '-<strong>SQL</strong> "RESTORE DATABASE [DatabaseForPartial<strong>Backup</strong>s]<br />

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

WITH NORECOVERY"'<br />

-- full partial backup restore<br />

EXECUTE master..sqlbackup '-<strong>SQL</strong> "RESTORE DATABASE [DatabaseForPartial<strong>Backup</strong>s]<br />

FROM DISK =<br />

''C:\<strong>SQL</strong><strong>Backup</strong>s\Chapter10\DatabaseForPartial<strong>Backup</strong>s_Partial_Full.sqb''<br />

WITH NORECOVERY"'<br />

-- differential partial backup restore<br />

EXECUTE master..sqlbackup '-<strong>SQL</strong> "RESTORE DATABASE [DatabaseForPartial<strong>Backup</strong>s]<br />

FROM DISK = ''C:\<strong>SQL</strong><strong>Backup</strong>s\Chapter10\DatabaseForPartial<strong>Backup</strong>s_Partial_Diff.sqb''<br />

WITH RECOVERY"'<br />

Listing 10-14: A <strong>SQL</strong> <strong>Backup</strong> script for full <strong>and</strong> differential partial restores.<br />

363

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

Saved successfully!

Ooh no, something went wrong!