Search code examples
powershellmsbuildsystemmanagement

Which tool / technology: System management for databases and dependent services


A follow-up on this system management question:

Since I probably will not get much feedback on serverfault I'll give it a try here.

My main concern is to reflect the dependencies between the databases, services ans tasks/jobs I'll have to manage.

Besides considering Powershell, I even thought about using MSBuild because it would allow for modeling dependencies and reuse configuration targets.

In other words: What technology should I use to develop a flexible solution that will allow me to stop service A, B and C on machine D in the right order and disable task E on machine F when taking down database X?

... and I'd like to reuse the part for stopping service B and C when taking down database Y.


Solution

  • If you are familiar with PowerShell and want to work with dependencies, try psake. What it looks like:

    psake script.ps1:-------
    properties {
     $dbServer = 'sqlexpress'
     ...
    }
    task default -depend StopServer1, StopServer2
    
    task StopS1 -depend MakeS1Backup, StopSqlServer1 {
     ...
    }
    task MakeS1Backup {
     ... make backup
    }
    task StopSqlServer1 {
     stop-service ...
    }
    # and anything similar to StopServer2
    

    Then you may call it like this (there are more options):

    Invoke-Psake script.ps1 
    #or
    Invoke-Psake script.ps1 -task StopS1 #calls only StopS1 task and all other scripts it depends on
    #or
    Invoke-Psake script.ps1 -task MakeS1Backup #only backups S1, it doesn't depend on anything else
    

    What it does - it stops server 1 (task StopS1) and before that it processes all the tasks that StopS1 depends on. So before stopping S1 backup of S1 is made and Sql server 1 is stopped and so on.

    I like it much better than msbuild configuration, which is very verbose and ugly (although very powerfull).