SlideShare une entreprise Scribd logo
1  sur  14
Automating restores and verification
to leave more time for the fun things
in a DBA’s job
 Started with SQL Server 7 in 1998, 15 years later
still working with it, but newer versions as well.
 Worked as DBA and Developer in that period.
 Also work with Oracle, MySQL and Linux
 In spare time I’m most likely to be found
studying a Mathematics degree with the OU, or
sat on a bike saddle somewhere remote.
 Email: stuart.moore@stuart-moore.co.uk
 Blog: http://stuart-moore.com
 Twitter: @napalmgram
 Started off as Monad back in 2005
 Improved with each version, now on version 3
 Lots of support for SQL Server:
◦ SMO – SQL Management Objects
◦ SQLPS – Official SQL Server Module, offers methods
for the above
◦ SQLPSX – Unofficial SQL Server Module
 Essential part of the job
 Easy to set up simple backup routines with
maintenance plans, not so easy for complex
setups
 Should be as essential as backups:
◦ Did the backup really complete properly?
◦ How long does a full restore take (how long should
RTO be)
◦ How long do the transaction backups take to
restore?
◦ Do you have whole backup chain
◦ If needed, can you prove it to Auditors?
 SQL Server doesn’t offer an easy means to
automate restores.
 Tend to need to build a job for each database
◦ Not easy with an instance with 100s of DB
◦ Differing file layouts also a problem
 Demos may not be the best examples of
PowerShell.
◦ I’ve taken some liberties to make them easier to
read
◦ Best practice is to write reusable functions, not lots
of scripts.
1. Basic Full backup of single db
2. Backup all DB on an instance
3. Catch new databases
4. Split Database backups
1. Simple Restore
2. Include transaction backups
3. Check transaction log order
4. Restore with file relocation
5. Restore to Random point in Time
 So now we’ve restored the database is that it?
 No, we need to check that it’s actually usable
and structurally sound.
◦ Run DBCC checks against
◦ Run our own scripts to check integrity or business
rules
 Corrupted DBs courtesy of Paul Randal from here -
http://bit.ly/1dEeklT
 Use Invoke-Sqlcmd
◦ Problems with query timeouts fixed in SQL Server
2012
◦ Versions prior to that, look at Invoke-Sqlcmd from
Chad Miller - http://bit.ly/16GOeL8
 Using DBCC
 Nothing other than SQL Server backup and
restores.
◦ Not a faster method
◦ Not a slower method
◦ Can be monitored just like all other backups
◦ Blocked by exactly the same things
 Not the world’s most informative error
messages:
◦ Plenty of error checking in production scripts
◦ Or get used to stepping through to find the
problems

Contenu connexe

En vedette

Ive got a powershell secret
Ive got a powershell secretIve got a powershell secret
Ive got a powershell secret
Chris Conte
 

En vedette (7)

Introduction To Power Shell
Introduction To Power ShellIntroduction To Power Shell
Introduction To Power Shell
 
Ive got a powershell secret
Ive got a powershell secretIve got a powershell secret
Ive got a powershell secret
 
SQL Server AlwaysOn for Dummies SQLSaturday #202 Edition
SQL Server AlwaysOn for Dummies SQLSaturday #202 EditionSQL Server AlwaysOn for Dummies SQLSaturday #202 Edition
SQL Server AlwaysOn for Dummies SQLSaturday #202 Edition
 
Power shell training
Power shell trainingPower shell training
Power shell training
 
Sql server infernals
Sql server infernalsSql server infernals
Sql server infernals
 
An Introduction to Windows PowerShell
An Introduction to Windows PowerShellAn Introduction to Windows PowerShell
An Introduction to Windows PowerShell
 
Introduction to powershell
Introduction to powershellIntroduction to powershell
Introduction to powershell
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

SQL Backups, Restores and Verification with SQL Sever

  • 1. Automating restores and verification to leave more time for the fun things in a DBA’s job
  • 2.  Started with SQL Server 7 in 1998, 15 years later still working with it, but newer versions as well.  Worked as DBA and Developer in that period.  Also work with Oracle, MySQL and Linux  In spare time I’m most likely to be found studying a Mathematics degree with the OU, or sat on a bike saddle somewhere remote.  Email: stuart.moore@stuart-moore.co.uk  Blog: http://stuart-moore.com  Twitter: @napalmgram
  • 3.  Started off as Monad back in 2005  Improved with each version, now on version 3  Lots of support for SQL Server: ◦ SMO – SQL Management Objects ◦ SQLPS – Official SQL Server Module, offers methods for the above ◦ SQLPSX – Unofficial SQL Server Module
  • 4.  Essential part of the job  Easy to set up simple backup routines with maintenance plans, not so easy for complex setups
  • 5.  Should be as essential as backups: ◦ Did the backup really complete properly? ◦ How long does a full restore take (how long should RTO be) ◦ How long do the transaction backups take to restore? ◦ Do you have whole backup chain ◦ If needed, can you prove it to Auditors?
  • 6.  SQL Server doesn’t offer an easy means to automate restores.  Tend to need to build a job for each database ◦ Not easy with an instance with 100s of DB ◦ Differing file layouts also a problem
  • 7.  Demos may not be the best examples of PowerShell. ◦ I’ve taken some liberties to make them easier to read ◦ Best practice is to write reusable functions, not lots of scripts.
  • 8. 1. Basic Full backup of single db 2. Backup all DB on an instance 3. Catch new databases 4. Split Database backups
  • 9. 1. Simple Restore 2. Include transaction backups 3. Check transaction log order 4. Restore with file relocation 5. Restore to Random point in Time
  • 10.  So now we’ve restored the database is that it?  No, we need to check that it’s actually usable and structurally sound. ◦ Run DBCC checks against ◦ Run our own scripts to check integrity or business rules  Corrupted DBs courtesy of Paul Randal from here - http://bit.ly/1dEeklT
  • 11.  Use Invoke-Sqlcmd ◦ Problems with query timeouts fixed in SQL Server 2012 ◦ Versions prior to that, look at Invoke-Sqlcmd from Chad Miller - http://bit.ly/16GOeL8
  • 13.  Nothing other than SQL Server backup and restores. ◦ Not a faster method ◦ Not a slower method ◦ Can be monitored just like all other backups ◦ Blocked by exactly the same things
  • 14.  Not the world’s most informative error messages: ◦ Plenty of error checking in production scripts ◦ Or get used to stepping through to find the problems