module 6 backup of sql server 2008 r2 databases. module overview backing up databases and...

22
Module 6 Backup of SQL Server 2008 R2 Databases

Upload: ada-small

Post on 31-Dec-2015

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Module 6

Backup of SQL Server 2008 R2 Databases

Page 2: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Module Overview

• Backing up Databases and Transaction Logs

• Managing Database Backups

• Working with Backup Options

Page 3: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Lesson 1: Backing up Databases and Transaction Logs

• Performing a Full Database Backup

• Working with Backup Sets

• Using Backup Compression

• Performing Differential Backups

• Performing Transaction Log Backups

• Demonstration 1A: Backing up Databases

Page 4: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Performing a Full Database Backup

BACKUP DATABASE AdventureWorks2008R2 TO DISK = 'L:\SQLBackups\AW.bak' WITH INIT;

BACKUP DATABASE AdventureWorks2008R2 TO DISK = 'L:\SQLBackups\AW.bak' WITH INIT;

• Backup entire database

• Backup active portion of log file

Page 5: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Working with Backup Sets

• A Backup Set represents one backup of any type

• Backup Sets are written to Media Sets Consists of one or more tape or disk Backup Devices

Backups are striped over the devices

Tape and disk devices cannot be mixed

• Backup devices and Media Sets are created the first time they are used

• Every backup device has a header with meta data of the backup sets

• Media Sets can be mirrored in Enterprise and Datacenter edition

Page 6: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Using Backup Compression

Backup Compression:

Restrictions:

Cannot co-exist on media with uncompressed backups

Cannot co-exist on tapes containing NT Backups

Compresses backup size on device

Introduced in SQL Server 2008üü

üü

üü

üü

Reduces I/O requirements, increases CPU usageüü

Faster backups but importantly, also faster restoresüü

Page 7: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Performing Differential Backups

BACKUP DATABASE AdventureWorks2008R2 TO DISK = 'L:\SQLBackups\AW_Diff.bak' WITH DIFFERENTIAL, INIT;

BACKUP DATABASE AdventureWorks2008R2 TO DISK = 'L:\SQLBackups\AW_Diff.bak' WITH DIFFERENTIAL, INIT;

• Backup the extents changed since the last full database backup

• Store active part of the transaction log to be able to recover the database

• Independent of other differential backups

Note: You cannot create a differential database backup if no full backup has ever been created

Page 8: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Performing Transaction Log Backups

BACKUP LOG AdventureWorks2008R2 TO DISK = 'L:\SQLBackups\AW_Log.bak' WITH NOINIT;

BACKUP LOG AdventureWorks2008R2 TO DISK = 'L:\SQLBackups\AW_Log.bak' WITH NOINIT;

• Backup the transaction log only

• Backs up log from the last successfully executed log backup to the current end of the log

• Truncates inactive log records unless options specified

Note: Database must be in full or bulk-logged recovery model

Page 9: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Demonstration 1A: Backing up Databases

In this demonstration you will see:

• How to backup a database

• How to use backup compression

Page 10: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Lesson 2: Managing Database Backups

• Options for Ensuring Backup Integrity

• Viewing Backup Information

• Demonstration 2A: Viewing Backup History

Page 11: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Options for Ensuring Backup Integrity

Mirrored Media Sets

• A backup set can be mirrored to up to 4 media sets• Mirrors require the same number of backup devices• Support in Enterprise and Datacenter Editions only

CHECKSUM backup option

• Available for all backup types• Generates a checksum over the backup stream• Can be used to verify the backup

Backup verification

• RESTORE VERIFYONLY can be used for backup verification• Useful when combined with the CHECKSUM option

Page 12: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Viewing Backup Information

• SQL Server 2008 R2 tracks all backup activity in a set of tables in the msdb database History can be accessed through T-SQL or SSMS

• Information can be retrieved from backup media RESTORE LABELONLY returns information about the backup

media on a specified backup device

RESTORE HEADERONLY returns all the backup header information for all backup sets on a particular backup device

RESTORE FILELISTONLY returns a list of data and log files contained in a backup set

Page 13: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Demonstration 2A: Viewing Backup History

• In this demonstration you will see: How to view backup history using SSMS

How to query the backup history tables using T-SQL

How to use the RESTORE HEADERONLY command to retrieve backup set information

Page 14: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Lesson 3: Working with Backup Options

• Backup Considerations

• Copy-only Backups

• Tail-log Backups

• Demonstration 3A: Tail-log Backup

Page 15: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Backup Considerations

• Backups are performed online Do not prevent user access Might slow down other operations due to I/O load

• Database must be online for normal backup operations Transaction log backups are still possible on a damaged

database Log file must be intact

• Integration with operating system options SQL Writer service provides backup functionality through the

Volume Shadow Copy Service (VSS) framework VDI interface enables ISVs to integrate backup and restore

functionality into their products (commonly used for 3rd party backup tools)

Page 16: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Copy-only Backups

BACKUP DATABASE AdventureWorks2008R2 TO DISK = 'L:\SQLBackups\AW_Copy.bak' WITH COPY_ONLY, INIT;

BACKUP DATABASE AdventureWorks2008R2 TO DISK = 'L:\SQLBackups\AW_Copy.bak' WITH COPY_ONLY, INIT;

• Backup the database without changing the restore order

• Copy-only transaction log backups do not truncate the log

• Copy-only full database backups do not affect the differential base

Note: Use COPY_ONLY for out of sequence backups

Page 17: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Tail-log Backups

• Used to capture the tail of the log before starting a restore sequence Performs a regular log backup

• Options: NORECOVERY when restore operations will follow (database set

to RECOVERING state)

CONTINUE_AFTER_ERROR when data files are missing or damaged but log files are intact

Performs a regular log backup

Page 18: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Demonstration 3A: Tail-log Backup

• In this demonstration, you will see how to backup the tail of the log of a damaged database

Page 19: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Lab 6: Backup of SQL Server Databases

• Exercise 1: Investigate backup compression

• Exercise 2: Transaction log backup

• Exercise 3: Differential backup

• Exercise 4: Copy only backup

• Challenge Exercise 5: Partial backup (Only if time permits)

Logon information

Estimated time: 45 minutes

Virtual machine 623XB-MIA-SQL

User name AdventureWorks\Administrator

Password Pa$$w0rd

Page 20: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Lab Scenario

You have reviewed and updated the recovery models. As the database administrator, you need to implement a database backup strategy. You have been provided with details of the required backup strategy for a number of databases on a SQL Server instance. You need to complete the required backups.

Page 21: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Lab Review

• What must be performed before you can create a differential backup of a database?

• How does a copy only backup differ from a full database backup?

Page 22: Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup

Module Review and Takeaways

• Review Questions

• Best Practices