The Codex of Business Writing Software for Real-World Solutions 2.pptx
Backup beyond just a strategy with SQL Server
1. Backup beyond just a strategy with SQL Server Vinod Kumar Technology Evangelist Microsoft Corporation www.ExtremeExperts.com http://blogs.sqlxml.org/vinodkumar
2. Session Objectives and Takeaways Session Objectives Know some of the basics of SQL Server What makes an effective Strategy for backup Both from Technology Enhancements Actual implementations Takeaways These as much as they look theoretical, We will view some of the fundamentals during the demo to make you realize how important backups are !!!
3. Targeted Roles Database Administration Database Development Database Operations and Support Database Solutions Architect
4. File Creation/Initialization Creation of database files Files being restored are created and initialized. This step is NOT performed if file already exists. Do not drop database prior to restoring it. Time requirement SQL Server 2000 Write throughput of data devices (disks, RAID controllers, etc.) Same time as CREATE DATABASE or ALTER DATABASE ADD FILE SQL Server 2005+ – Zero-initialization SKIPPED
5. Data/Transaction Log Copy File containing data or transaction log is copied from backup devices to destination Length of this phase: Amount of data or log to be copied Slowest component of the I/O system (disk device, backup device, controller, PCI bus, network) System tuned for maximum copy speed is limited by memory bus bandwidth—or before that, number of PCI buses or slots supported by system CPU usage should be insignificant
6. Redo Redo (or roll-forward) occurs after the log has been restored. Reads the transaction log. Reapplies changes recorded in log to data pages so all pages are consistent with log. Length of this phase is determined by… Amount of log to redo (affected by type and frequency of backups), and System performance. Planning: How fast is redo relative to production workload?
7. Undo Undo is also called “roll-back” or “recovery.” Begins after redo reaches it target point, often the point of failure. Changes that were applied by active, uncommitted transactions at the target point are undone. Length of this phase: The amount of data modified by the active transactions Planning: Very hard – depends on how transactions have been written and/or if long running transactions exist…
8. Phases of Restore File Creation/Initialization Same as CREATE DATABASE Minimized by Skipping zero-initialization Data and/or Transaction Log Copy Based on Media type and DB Size Minimized by Optimizing HW Configuration and Throughput Redo/Roll-forward Log Type/Frequency of Backups Minimized by SQL Server Transaction Log Information Undo Uncommitted Transactions Impossible to predict Database Accessible upon REDO completion!
9. Instant File Initialization Skip data file zeroing Create VLDB, Add or grow file, Initialize for restore, …in seconds! Security Prior disk contents not overwritten until used Extra care if SQL Server shut down or DB detached Secure by default Permission grantable only by Windows administrator
10. Online Restore SQL Server 2000 One damaged page/device/file ENTIRE database marked suspect, taken “offline” Database is not available during restore SQL Server 2005+ onwards Database remains online Only data being restored is unavailable File/filegroup restore
11. Piecemeal ManagementFine Grained Operations Operations affect the minimum amount of data Pages Filegroups Partitions Data not involved remains Available Performant
12. FilegroupsBasic unit of availability Earlier Versions of SQL Server Entire database SQL Server 2005+ Database can be online, yet not all filegroups are available
13. Available Primary Filegroup Database Filegroup A Filegroup B ExamplePiecemeal restore for disaster recovery Online restore of filegroups in priority order Backups Primary Log Filegroup A Filegroup B
14. Piecemeal Backup-Restore Partial database availability during restore Based on file/filegroup backup Works with all recovery models Full, Simple, Bulk-Logged Supported only for databases with multiple filegroups Filegroups must be recovered to consistent point
15. Short Restore SequenceFor Read-Only Data Log backups need not be restored when… File/filegroup is unchanged since backup File has been rolled forward to where it is read-only Useful for read-only tables or partitions Set filegroup read-only Recommended for FULL and BULK-LOGGED databases Prevents inadvertent change Prevents changes by background tasks Required for SIMPLE model databases Log backup for roll forward not available
16. Primary Filegroup Filegroup A RESTORE DATABASE D… FILEGROUP=‘B’ Available Restore Damaged FilegroupFull model database Log Backups Primary Backup Database Filegroup A Backup Filegroup B Backup Filegroup B Read - Only Filegroup C Backup Filegroup C Read - Only
17. Recovery Models - Glance Full No work loss Supports recovery to any point-in-time Simple Simplest backup/restore strategy Simplifies log management No log backups Greatest work loss possible No point-in-time recovery No access to tail Bulk_Logged High performance bulk operations Minimal log space for bulk operations Some work loss exposure Many large data warehouses fit this model
18. Partial Backups Two new types of backup Partial Database Similar to a full database backup, but contains only the read-write filegroups Partial Differential Similar to a full database differential, but contains only the read-write filegroups Added to allow piecemeal restore of simple model databases Also work with full and bulk-logged models
19. Piecemeal Backup-RestoreSimple Model Databases Required backups Partial database backup File or filegroup backups of read-only filegroups Must be consistent with partial Optional backups Partial differential File/filegroup differential If filegroup normally read-only was changed, then made read-only again
20. BACKUP DATABASE D… WITH PARTIAL Primary Filegroup Filegroup A BACKUP DATABASE D… FILEGROUP=‘B’ BACKUP DATABASE D… FILEGROUP=‘C’ Piecemeal BackupSimple model database Database Partial Backup Filegroup B Backup Filegroup B Read - Only Filegroup C Backup Filegroup C Read - Only
21. RESTORE DATABASE D… WITH PARTIAL Primary Filegroup Filegroup A RESTORE DATABASE D… FILEGROUP=‘B’ Filegroup B Read - Only RESTORE DATABASE D… FILEGROUP=‘C’ Filegroup C Available Read - Only Piecemeal RestoreSimple model database Database Partial Backup Filegroup B Backup Filegroup C Backup
22. Primary Filegroup Filegroup A RESTORE DATABASE D… FILEGROUP=‘B’ Available Restore Damaged FilegroupSimple model database Database Partial Backup Filegroup B Backup Filegroup B Read - Only Filegroup C Backup Filegroup C Read - Only
23. Unavailable RESTORE DATABASE D… WITH PARTIAL Available Restore Damaged PrimarySimple model database Database Partial Backup Primary Filegroup Filegroup A Filegroup B Backup Filegroup B Database Primary and A may be taken back in time without restoring filegroups B and C if B and C are consistent Read - Only Filegroup C Backup Filegroup C Read - Only
24. Damaged Page Tracking And Restore Damaged pages encountered on read Torn page or checksum error Bad Page ID Short read Database remains available Transaction rolls back BUT error during rollback forces database restart Damaged pages Automatically tracked in a table May be restored and recovered online Works for databases with a single filegroup
25. Page Restore Versus File Restore Consider page restore when… You have a limited number of damaged pages You must maintain maximum availability Consider file restore when… A device is failing You have large numbers of damaged pages You need to relocate data to another device You can tolerate the affected filegroupbeing unavailable
26. Data Page Verification Types Torn page detection – 7.0 and 2000 Page checksum – NEW! Page checksum Detect disk I/O errors not reported by the hardware or operating system When the checksum is verified Retries eliminate transients If verification fails, A unique error is raised Connection is terminated Page is tracked
27. Backup Verification Detect errors unreported by the backup devices or operating system Backup checksums are optionally generated Verified by RESTORE RESTORE VERIFYONLY Backup optionally validates page checksums if these are present Optionally continue past page checksum errors to complete the backup
28. Continue Past Restore Errors Why? A damaged backup may be the only one available Continue past errors encountered by RESTORE RESTORE VERIFYONLY Allows the restore sequence to continue as far as possible… Affected file groups are left in suspect state
29. Backup/RestoreMirrored Media Sets Redundant backup media helps guarantee successful restore Extra copies for Archival Disaster recovery
31. 31 Summary Backups are the most important step in restoring your DB in event of failure Maybe your first and last resort Must understand the effects of using them Know ALL the options in handling disaster All the Best !!!