SQL LiteSpeed 3.0 Best Practices Optimize SQL LiteSpeed to gain value time and resources for critical SQL Server Backups September 9, 2003 Written by: Jeremy Kadlec Edgewood Solutions www.edgewoodsolutions.com 888.788.2444
2 Introduction This document outlines best practices for SQL LiteSpeed 3.0 as a set of guidelines for most SQL Server environments with typical configurations in the following areas: Backup and Restore Best Practices Backup Options SQL LiteSpeed Backup Syntax and Configurations SQL LiteSpeed Restore Syntax and Configurations Backup and Restore Best Practices Below outlines the recommended SQL LiteSpeed 3.0 backup and restore best practices: Test the backup and restore process when the plan is initially created, when backup procedures change and every quarter to verify the plan is operating properly and to update the documents Backup all system and user databases with full, differential and/or transaction log backups on a predefined basis providing a suitable level of database recovery Setup each database with the appropriate Recovery Model Full, Bulk Logged or Simple Review the SQL Server Error Logs following backup and restore operations Setup backups as SQL Server Jobs to automatically execute on a predefined basis If another product, such as Veritas or BrightStor (formerly ARCserve) is responsible for the file system backups setup the SQL Server Jobs to execute ahead of time or as a Pre-Job for the file system backup product o For additional information and options review the article - Integrating SQL LiteSpeed in your existing Backup Infrastructure - (http://www.edgewoodsolutions.com/resources/integratingsqllitespeed.asp) o Configure the file system backup agents to either only backup the SQL Server database backups or to skip the directories where the online databases reside (i.e. C:\Program Files\Microsoft SQL Server\MSSQL\Data\) so no false-positive error messages are inappropriately generated Backup to disk first for performance and recoverability and then to tape for permanent archive Backup to a dedicated redundant disk sub system for backups i.e. RAID 5, RAID 1 or RAID 10 o If a dedicated disk drive is not available backup to a physical disk drive where the databases and transaction logs are not currently stored o If a drive fails that houses the online databases, transaction logs and backups then it is possible to have little to no recovery options o Execute System Monitor to ensure the disk subsystem is not stressed prior to the backups and once the backups begin to store the backup files on disk by monitoring the Disk Queue length of the physical and logical disk sub system; by most accounts the Disk Queue length should be two or less
3 Retain one to seven days of backups on disk as disk space permits o Verify sufficient disk space is available for backups by reviewing the volume information in Windows Explorer or executing the following command in Microsoft SQL Server Query Analyzer - EXEC master.dbo.xp_fixeddrives Execute the verify only option for backups on a nightly or weekly full database backup to ensure backup integrity for 100% assurance the backup will properly restore Execute DBCC statements on a weekly or monthly basis to ensure the integrity of the databases o If the SQL Server platform has demanding 24 X 7 constraints issue the DBCC s on a backup or secondary system Encrypt all SQL Server backups because portions of the file containing business critical data can be read with a text editor and compromise the security of the backups o Record the encryption key in a secure location and change on a regular basis Institute Alerts and Operators to automate notification for the IT staff responsible for backups o For additional information review the following article - Alert! Alert! Alert! Backup and Restore Baby! (http://www.edgewoodsolutions.com/resources/articles.asp) Setup Log Shipping to a secondary SQL Server for additional database availability options Ensure no connections are held to the database when executing a database restore Supported Versions - SQL LiteSpeed Windows and SQL Server should be compliant with the following Service Packs for SQL LiteSpeed as of September 2003: SQL LiteSpeed 3.0 Service Pack Requirements OS Version Service Pack Windows NT 4.0 Service Pack 6a SQL Server Version SQL Server 7.0 Service Pack Service Pack 3 or above Windows NT 4.0 Service Pack 6a SQL Server 2000 Latest (Service Pack 3a) Windows 2000 Windows 2000 Latest (Service Pack 4) Latest (Service Pack 4) SQL Server 7.0 SQL Server 2000 Service Pack 3 or above Latest (Service Pack 3a) Windows 2003 Latest (Service Pack 1) SQL Server 2000 Latest (Service Pack 3a) SQL Server Backup Options with SQL LiteSpeed Below outlines three SQL Server backup options to serve as a baseline strategy to meet general backup needs with a varying level of complexity: Full SQL Server Backups Full and Differential SQL Server Backups Full, Differential and Transaction Log SQL Server Backups
4 Description Advantages Disadvantages Option 1 Full SQL Server Backups Backup Type Full SQL Server backups executed daily i.e. after business hours at 11:59 PM Automation Setup SQL Server Jobs with intuitive names for daily full backups of all system and user databases that are copied to a centralized location for tape archive Recovery Process Apply the full database backup Automated daily backups are executed at a predefined time Non logged operations can be issued Simple recovery process to bring the databases online Performance degradation from backups is not noticeable The amount of additional disk space required prior to the copy to the centralized location for tape archive is less than the size of the database based on SQL LiteSpeed s compression capabilities A significant amount of data loss can be incurred (i.e. 24 hours) depending on the point in time when the recovery process needs to begin since it is from the last full database backup Description Advantages Disadvantages Option 2 Full and Differential SQL Server Backups Backup Type Full SQL Server backups executed daily with differential backups either once in the morning and once in the afternoon (10:30 AM and 2:30 PM) or every two hours starting at 8:00 AM (8:00 AM, 10:00 AM, 12:00 PM, 2:00 PM, 4:00 PM, 6:00 PM) Automation Setup SQL Server Jobs with intuitive names for daily full and differential backups of all system and user databases that are copied to a centralized location for tape archive Recovery Process Apply the most recent full database backup and then the all of the differential backups for the day Automated daily backups are executed at predefined times Moderate recovery process to bring the databases online Performance degradation from backups is not noticeable The amount of additional disk space required prior to the copy to the centralized location for tape archive is less than the size of the database based on SQL LiteSpeed s compression capabilities A moderate amount of data loss can be incurred i.e. two hours Description Advantages Disadvantages Option 3 Full, Differential and Transaction Log SQL Server Backups Backup Type Full SQL Server backups executed daily with differential backups either once in the morning and once in the afternoon (10:30 AM and 2:30 PM) or every two hours starting at 8:00 AM (8:00 AM, 10:00 AM, 12:00 PM, 2:00 PM, 4:00 PM, 6:00 PM) with transaction log backups every 5 to 15 minutes Automation Setup SQL Server Jobs with intuitive names for daily full, differential and transaction log backups of all system and user databases that are copied to a centralized location for tape archive Recovery Process Apply the most recent full database backup and then the all of the differential backups for the day and the transaction log backups since the last differential backup Automated daily backups are executed at predefined times Ability to lose no transactions Moderate to high recovery process to bring the databases online Performance degradation from backups is not noticeable The amount of additional disk space required prior to the copy to the centralized location for tape archive is less than the size of the database based on SQL LiteSpeed s compression capabilities Non logged operations cannot be issued because the subsequent transaction logs cannot be applied
5 SQL LiteSpeed Backup Syntax and Configurations Database Level Backups 1 Full database backup that initializes the file, uses three threads, an encryption key of EdgewoodSolutions, compression level of 1, a priority of 0 and logging if a problem occurs EXEC master.dbo.xp_backup_database @database='mydb',@filename='c:\mssql\backup\mydb_fullbackup.bak',@init=1,@threads=3,@compressionlevel=1,@priority=0 Differential Backups 1 Differential database backup that initializes the file, uses three threads, an encryption key of EdgewoodSolutions, compression level of 1, a priority of 0 and logging if a problem occurs EXEC master.dbo.xp_backup_database @database='mydb',@filename = 'C:\MSSQL\Backup\MyDB_DiffBackup.BAK', @with = 'DIFFERENTIAL',@init=1,@threads=3,@compressionlevel=1,@priority=0 Transaction Log Backups 1 Transaction log backup that initializes the file, uses three threads, an encryption key of EdgewoodSolutions, compression level of 1, a priority of 0 and logging if a problem occurs EXEC master.dbo.xp_backup_log @database = 'MyDB',@filename='C:\MSSQL\Backup\MyDB_TLOGBackup.BAK',@init = 1,@threads=3,@compressionlevel=1,@priority=0 File and File Group Backups 1 File Group backup that backs up the Primary File Group and initializes the file EXEC master.dbo.xp_backup_database @database='mydb', @filename= 'C:\MSSQL\Backup\MyDB_FileGroupBackup.BAK', @filegroup = 'PRIMARY', @init= 1
6 SQL LiteSpeed Tuning Configurations Compression Level o @compressionlevel = 1 o @compressionlevel is only available for SQL LiteSpeed versions 2.6.X to 2.9.X and will no longer be available after SQL LiteSpeed 3.0, but SQL LiteSpeed 3.0 will perform like the current value of 1 Latency o Do not include this parameter Priority o @priority=0 Threads o Below outlines the thread recommendation based on the number of physical CPUs ID Physical CPUs Thread Recommendation 1 1 1 2 2 1 3 4 3 4 8 6 5 16 13 6 32 28 If hyper threading is enabled on the SQL Server use the thread recommendations outlined above in a test environment and increase the number of threads by no more than 20% of the thread recommendation listed above. For example, if a server has 8 physical CPUs with hyper threading enabled 16 CPUs will be recognized. Test originally with 6 CPUs and test thoroughly with 8 to 10 CPUs. Note If a SQL Server is processor bound consider specifying less threads. To determine the stress on the CPUs, execute System Monitor and record the Processor Queue length prior to and during the backups. The Processor Queue length should be between zero and two, not exceeding two in most circumstances. For additional reference SQL LiteSpeed Online help or the following article - Backup and Restore Back to Basics with SQL LiteSpeed (http://www.edgewoodsolutions.com/resources/backupandrestorelitespeed.asp).
7 SQL LiteSpeed Restore Syntax and Configurations Full Database Restore 1 Full database restore that uses an encryption key of EdgewoodSolutions and logging if a problem occurs EXEC master.dbo.xp_restore_database @database = 'MyDB', @filename= 'C:\MSSQL\Backup\MyDB_FullBackup.BAK' Database Restore to a point in time 1 Transaction Log restore that recovers the database, stops at a particular time, uses an encryption key of EdgewoodSolutions and logging if a problem occurs EXEC master.dbo.xp_restore_log @database='mydb', @filename = 'C:\MSSQL\Backup\MyDB_TLOGBackup.BAK', @with = 'RECOVERY', @with = 'STOPAT = "2003-03-19 11:10:57.000"' Database Restore WITH MOVE 1 Full database restore that moves the database during the restoration, uses an encryption key of EdgewoodSolutions and logging if a problem occurs Resources EXEC master.dbo.xp_restore_database @database='mydb', @filename = 'C:\MSSQL\Backup\MyDB_FULLBackup.BAK', @with = 'MOVE "MyDB_Data" TO "C:\MSSQL\Data\MyDB_Data.MDF"', @with = 'MOVE "MyDB_log" TO "C:\MSSQL\Data\MyDB_Log.LDF"' 1. SQL LiteSpeed 3.0 Online Help DBAssociatesIT Access 09.01.2003 2. Backup and Restore Back to Basics with SQL LiteSpeed Greg Robidoux Edgewood Solutions - www.edgewoodsolutions.com/resources/backupandrestorelitespeed.asp Access 09.01.2003 3. Integrating SQL LiteSpeed in your existing Backup Infrastructure Jeremy Kadlec Edgewood Solutions - www.edgewoodsolutions.com/resources/integratingsqllitespeed.asp Access 09.01.2003 4. Spotlight - SQL LiteSpeed Return on Investment Greg Robidoux Edgewood Solutions - www.edgewoodsolutions.com/resources/litespeedroi.asp Access 09.01.2003 5. www.dbassociatesit.com DBAssociatesIT - Access 09.01.2003
8 Additional Information For additional information about SQL LiteSpeed contact Craig Allen of Edgewood Solutions at 1.888.788.2444 or email Craig at craiga@edgewoodsolutions.com. Visit the following URLs for additional information: Download a SQL LiteSpeed Trial www.edgewoodsolutions.com/partners/dbassociates.asp Backup and Restore Back to Basics with SQL LiteSpeed www.edgewoodsolutions.com/resources/backupandrestorelitespeed.asp Integrating SQL LiteSpeed in your existing Backup Infrastructure - www.edgewoodsolutions.com/resources/integratingsqllitespeed.asp Spotlight - SQL LiteSpeed Return on Investment - www.edgewoodsolutions.com/resources/litespeedroi.asp The SQL Server Storage Stomper = SQL LiteSpeed - www.edgewoodsolutions.com/resources/litespeedstoragestomper.asp SQL LiteSpeed 3.0 Installation Guide - www.edgewoodsolutions.com/resources/articles.asp DBAssociatesIT the maker of SQL LiteSpeed - www.dbassociatesit.com Stay tuned for, Alert! Alert! Alert! Backup and Restore - Baby!!! and The SQL LiteSpeed 3.0 Step-By-Step Guide at www.edgewoodsolutions.com in the September 2003 time frame About the Author - Jeremy Kadlec Jeremy Kadlec is the Principal Database Engineer at Edgewood Solutions, (www.edgewoodsolutions.com) a technology services company delivering full spectrum Microsoft SQL Server Services on the east coast of the United States primarily in the Washington DC and Boston areas. He is also the author of the Start to Finish Guide to IT Project Management (http://www.edgewoodsolutions.com/services/ebookprojectmanagement.asp). Jeremy can be reached at 410.591.4683 or jeremyk@edgewoodsolutions.com. Learn more about how Edgewood Solutions delivers databases at their finest at www.edgewoodsolutions.com. Copyright 2002-2003 Edgewood Solutions All Rights Reserved Some names and products listed are the registered trademarks of their respective owners.