Restore Script from Backup Directory – Modified

As a DBA your job is to protect the data, whether that be from corruption, attack, developers or any other host of unknown afflictions. While I was not involved in the day to day backup or recovery while acting as an Accidental DBA (handled by an MSP), nor do I handle those duties in my current role as an actual DBA (handled by Storage Team) I am very aware of the needs of a solid strategy for backup AND recovery.

As I was tuning my next presentation which will introduce the uninformed to Ola Hallengren’s portfolio of free utilities I realized that teaching new or aspiring DBAs about the importance of a backup plan is reckless unless you also tell them about the importance of the more important, a recovery plan. I recalled having read a write-up by Greg Robidoux at MSSQLTips.com for a script to automatically generate a recovery script, based off a folder full of backups.

Once I looked at the requirements Greg lays out in his script I saw that it would not work as-is with Ola’s solution, so I modified it to do just that.

Now, as a warning, there is nothing earth shattering here, just a simple rework of a great solution for your toolbox. If you use Ola’s tools, maybe you can add this as an item in your tool box, as always, all feedback is greatly appreciated.

 

 

  • Me

    Great script! Have you thought about adding a parameter to specify a point-in-time restore?

  • Haven’t had the need, but I can give it a shot.

  • Pingback: Automated restore using Ola Hallengren’s SQL Server Backup | codepimp()

  • William

    Hi Jason,
    Thank you for this script. Great Job!
    Couple of changes made the trick for me to adapt it to my environment,
    Also, I was looking at ‘STOPAT’ parameter in order to indicate a point in time, I am a bit stuck with it.
    Do you have any clue?
    Your help would be appreciated.
    Regards,

  • Evans Owusu

    What should i replace the ' with.and do the script restores backup across multiply files.

  • BrentO

    Howdy sir! It looks like your code got mangled by your HTML formatter – can you copy/paste it into the post again? That should fix the quotation marks.