Backup Estos MetaDirectory 4.0

This is an update to my previous post describing the steps to create backups ESTOS applications. The older post handled backing up the earlier release 3.5 of MetaDirectory.

In the meantime MetaDirectory 4.0 has been released and with the new release ESTOS changed the installation path and the name of the service so that the current backup script will not work anymore.

So it’s time for a small update.

The challenge

In order to not adjust the script every time I want to deploy it again on another server, I want a script that works for the older and the actual version. So I have to check and adjust the values for service name and paths used within the script.

If there is a 3.5 version running we will backup this, if we have a 4.0 version we copy that and if there is no MetaDirectory we just skip to backup that.

This way we also don’t have to enable or disable MetaDirectory backup but just have to let the script decide what has to be done and what has to be skipped.

The implementation

We will reach our goal in three steps:

    • Get the name of te MetaDirectory service
    • Based on the name set variables for service name and installation path
  • Call the backup function

Get the service name

First we have to get the name of the service and we know that possible names are ‘emeta3’ (release 3.5) and ‘emeta’ (release 4.0):

$(Get-Service -Name "emeta*").Name

Here we list the service with a name that starts with ‘emeta’ (-Name “emeta*”). To not produce error messages we ensure that even if there is no matching service the script just continues (-ErrorAction SilentlyContinue). In the last step we let the result bahave like a variable by putting the command into brackets prefixed by the dollar sign so that we can get the property ‘Name’.

The value of that property can be either ‘emeta3’ (release 3.5) or ‘emeta’ (release 4) or it can be empty (no MetaDirectory installed).

Set variables and call the backup function

Based on the values we set variables for the paths to get a copy of and the service name we have to stop and start during the backup. To avoid a chain of if-then-else statements and to be able to add further options to cover later versions easily we use the switch statement. Using switch we can run commands based on the result of the command listed before:

switch ($(Get-Service -Name "emeta*").Name)
    {
    emeta3
        {
        $metadbsource = 'C:\Program Files (x86)\ESTOS\MetaDirectory 3.5\databases'
        $metaconfsource = 'C:\Program Files (x86)\ESTOS\MetaDirectory 3.5\config'
        $metaservice = 'emeta3'
        metadirbackup
        }
    emeta
        {
        $metadbsource = 'C:\Program Files\estos\MetaDirectory\databases'
        $metaconfsource = 'C:\Program Files\estos\MetaDirectory\config'
        $metaservice = 'emeta'
        metadirbackup
        }
    default
        {
        }
    }

Optionally we can set a default action if nothing else matches. Therefore we have to call the value ‘default’ as the last one and define what to do then. In this case that is not necessary because we will not call the function if no ‘emeta*’ service exists.

As you can see the original function is adjusted to use variables instead of fixed values for the used paths and the service name to have one single function that works for all versions of MetaDirectory.

You can download the full MetaDirectory backup script here: MetaDirBackup

Conclusion

Now we have a backup script for ESTOS MetaDirectory that works for all versions I used. I didn’t check the installation path and service names of earlier releases so that I can’t guarantee that this script will work for other versions that 3.5 and 4.0. It seems that ESTOS decided to stripe any version information out of the service name and paths so that I guess this will work for following releases as well.

If you have questions please feel free to use the comment option below. You can also contact me if you feel that I should cover other tasks.

As a nice tool to check Powershell commandlets and their options I recommend to have a look into the app ‘Powershell reference’ that covers not only Windows commands but also Microsoft Exchange, Azure, Citrix or VMWare’s PowerCLI.

The app was not found in the store. 🙁

Leave a Reply

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