Presentation is loading. Please wait.

Presentation is loading. Please wait.

Automated Restore Script Output for Ola Hallengren’s Maintenance Solution 1) Start SQL Services on Local 2) Connect to Azure AlwaysOn 3) Delete all maintenance.

Similar presentations


Presentation on theme: "Automated Restore Script Output for Ola Hallengren’s Maintenance Solution 1) Start SQL Services on Local 2) Connect to Azure AlwaysOn 3) Delete all maintenance."— Presentation transcript:

1 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution
1) Start SQL Services on Local 2) Connect to Azure AlwaysOn 3) Delete all maintenance solution jobs

2 Jared Zagelbaum MCSE Data Management & Analytics
Featured blogger at SQLServerCentral.com Technical Editor for SQL Server Publications Consultant and Solutions Architect 2 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

3 Ola Hallengren https://ola.hallengren.com E-mail: ola@hallengren.com
DBA with Saxo Bank, a Danish investment bank Microsoft MVP – SQL Server 3 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

4 Solution Overview SQL Server 2005* - 2016 Based on stored procedures
SQL Server 2005 end of support was April 12, 2016 Based on stored procedures DatabaseBackup DatabaseIntegrityCheck IndexOptimize CommandExecute It’s free! Download and install maintenance solution at end of slide using all defaults 4 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

5 Common Parameter Declarations
@Databases Common Parameter across DatabaseBackup, IndexOptimize, and DatabaseIntegrityCheck Value Description SYSTEM_DATABASES All system databases (master, msdb, and model) USER_DATABASES All user databases ALL_DATABASES All databases Db1 Database Db1 Db1, Db2 Databases Db1 and Db2 USER_DATABASES, -Db1 All user databases except Db1 %Db% All databases that have “Db” in the name %Db%, -Db1 All databases that have “Db” in the name except Db1 ALL_DATABASES, -%Db% All databases that do not have “Db” in the name 5 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

6 DatabaseBackup Full, differential, and transaction log backup
Backup to local drives, network shares, or Azure Blob Storage Mirroring and / or striping of backups to multiple files Supports AlwaysOn Availability Groups Checksum, Compression, and Encryption Supports Red Gate SQL Backup, LiteSpeed, and Idera SQL Safe Automatic handling of new databases @ChangeBackupType 6 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

7 Backup of AlwaysOn Availability Groups
Define a backup preference for the Availability Group Prefer Secondary (Default) Secondary only Primary Any Replica Backup types supported on secondary replicas Copy-only full backups Regular transaction log backups Function to check preferred backup replica Sys.fn_hadr_backup_is_preferred_replica 7 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

8 DatabaseBackup Availability Group Logic
Backup type Backup performed on Full backup Primary replica Full backup copy_only Preferred replica Differential backup Transaction log backup 8 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

9 DatabaseIntegrityCheck
DBCC CHECKDB DBCC CHECKFILEGROUP DBCC CHECKTABLE DBCC CHECKALLOC DBCC CHECKCATALOG Options for PHYSICAL_ONLY and NOINDEX 9 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

10 IndexOptimize Checks fragmentation
Defines three different fragmentation groups: low, medium, and high Fully configurable thresholds and maintenance actions Defaults to Microsoft recommended thresholds and actions Low fragmentation <5% (Index < 1000 pages) No Action Medium fragmentation between 5 and 30% Reorganize Index High fragmentation >= 30% Rebuild Index (Online if possible) Supports AlwaysOn Availability Groups Index maintenance performed on primary replica Updates statistics (skips rebuilt indexes) 10 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

11 Index Maintenance – Rebuild and Reorganize Limitations
Online rebuild only available in Enterprise Edition Xml indexes and spatial indexes cannot be rebuilt online Indexes with image or text cannot be rebuilt online Indexes with varchar(max), nvarchar(max), or varbinary(max) can be rebuilt online in SQL Server 2012 or later Index partitions can be rebuilt online only in SQL Server 2014 or later An index with page locking disabled cannot be reorganized 11 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

12 Solution Implementation
CommandExecute Wrapper procedure that implements standardized logging throughout the components of the maintenance solution CommandLog CommandExecute writes maintenance solution procedures execution results to this table = ‘Y’ = ‘N’ for maintenance procedures = ‘Y’ for SQLCMD job steps when created using maintenance solution script 12 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

13 Solution Implementation (continued)
SQL Server Agent CmdExec Job Step Sqlcmd and the –b option Execution continues on after error SQL Agent job reports failure in the end SQL Server Agent Tokens Uses SRVR for the local SQL Server instance Uses SQLLOGDIR (new in 2014) for the output file directory Uses JOBID, STEPID, STRTDT, and STRTTM to create unique output file names Error log: C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log Can be found in config manager startup settings 13 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

14 DR and Availibility Planning
Maintenance Solution DB health Automated backups Availability requirements RPO RTO Schedule, Drill, Repeat!!!!! 14 | 10/10/2015 Automated Restore Script Output for Ola Hallengren’s Maintenance Solution

15 …not just me “The real problem isn’t backups – it’s communication. Being a truly exceptional DBA means that your manager, plus every level all the way up the chain, is comfortable with your (in)ability to restore every system in the shop. Your managers have a list in writing of all the company’s systems, a high-level overview of how frequently they’re backed up, how frequently the restores are tested, and how long a restore will take.” -Brent Ozar 10/10/2015 Session Title Here

16 DR Scenarios Houston…we have a problem Instance / database responsive
If possible, always take tail log backup before restore (Full recovery model) Use Recovery Advisor Backup files What to restore RTO include time to hunt and identify correct .bak(s) and .trn(s)!? 10/10/2015 Session Title Here

17 Automated Stand by Restore Script
Extends Maintenance Solution RestoreCommand Adds additional job step to DatabaseBackup jobs Requirements @LogToTable = ‘Y’ At least one full backup logged to CommandLog Job to manage script file cleanup (template provided) 10/10/2015 Session Title Here

18 Restore Script solution limitations
Mirroring / Striping unsupported Some complexities around Availability Group implementation ***User base + feedback = more features!*** 10/10/2015 Session Title Here


Download ppt "Automated Restore Script Output for Ola Hallengren’s Maintenance Solution 1) Start SQL Services on Local 2) Connect to Azure AlwaysOn 3) Delete all maintenance."

Similar presentations


Ads by Google