SlideShare a Scribd company logo
1 of 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

More Related Content

Viewers also liked

Introduction To Power Shell
Introduction To Power ShellIntroduction To Power Shell
Introduction To Power ShellIvan Suhinin
 
Ive got a powershell secret
Ive got a powershell secretIve got a powershell secret
Ive got a powershell secretChris Conte
 
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 EditionMark Broadbent
 
Power shell training
Power shell trainingPower shell training
Power shell trainingDavid Brabant
 
An Introduction to Windows PowerShell
An Introduction to Windows PowerShellAn Introduction to Windows PowerShell
An Introduction to Windows PowerShellDale Lane
 
Introduction to powershell
Introduction to powershellIntroduction to powershell
Introduction to powershellSalaudeen Rajack
 

Viewers also liked (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
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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 WorkerThousandEyes
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 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