Upgrading Ola Hallengren’s Maintenance Solution with dbatools

While presenting Backup Basics with Powershell and dbatools at ONDT, I mentioned a caveat with the -ReplaceExisting switch for Install-DbaMaintenanceSolution. This switch drops all of the objects installed by the Maintenance Solution, including the CommandLog table. If you use that table to produce evidence that the various maintenance tasks are being performed on a regular basis or use it to track performance of those tasks over time, dropping that table presents a problem.

The question of how to upgrade the Maintenance Solution via dbatools was raised. If -ReplaceExisting has those pitfalls, there must be another way to update it, right? My takeaway from the presentation was to find out what that method is.

As it turns out, you can’t do this as far as I can tell. At least not in the current incarnation of Install-DbaMaintenanceSolution. There’s an open issue in dbatools to address this, #6512

Until this enhancement is implemented, the workaround is to download the script(s) either from Ola’s website or his GitHub repository. Run each of the .sql files (except for MaintenanceSolution.sql) individually to install the updated stored procedures, and you’ll be set.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: