SQL server update patching

I am looking to include a step in an existing process for a project that currently does automated patching for our various systems. The problem that I’m facing is that sometimes after installing updates, the server needs to reboot.

After rebooting, there can be additional updates available which would require another install and reboot, and so on. The current solution is to have many copies of the same check for updates and reboot script in the process so that there is enough to be sure that all updates are installed, but this solution looks cluttered and I would like a cleaner solution.

The obvious answer would be a loop that calls this script until no updates are left to install, but from my knowledge Octopus does not support loops within the process. I also though of using a loop within the powershell script but it doesn’t work because the script will exit the loop once the target machine restarts. As such, I was hoping someone could lend insight into what the best way to achieve my goals is.

Hi @wfitzmaurice,

Quick question, are your SQL Servers physical machines or virtual machines? If they are virtual machines, do you have access to run scripts on the hosting platform (VMWare, Azure, AWS, GCP, etc.).

The reason I ask is if they are VMs, typically what I recommend is running a script to reboot the machines on the hosting platform. That way, if the server doesn’t come up, you have the ability to run additional scripts.

In regards to needing additional updates, if possible, I’d recommend running a script at the end of your process to look for updates. If updates are found, then kick-off a fresh deployment/runbook run using the CLI.

So your process would look like:

  1. Run Updates
  2. Reboot Server
  3. Check for additional updates / if found, use the CLI to start a new deployment/runbook run, if not found then exit.