With the new server up and running it seemed fitting to connect it to my UPS, and thanks to the low power consumption of the HP Microservers I still get around 40 minutes of battery only time with both servers running before the UPS runs out of juice.
Unfortunately, the UPS in use only has one monitoring port which is connected to my original server, meaning during a spell of prolonged power outage, the new server will not know when to shut down safely and will continue to run until the UPS runs out of battery supply, leaving it vulnerable to data corruption that affected the original server prior to battery backup.
But with a simple script and some setup both servers can shut down safely before the batteries run out.
The Idea is to have a script sent from the host server with instructions to shut down the other server when the battery level runs low, luckily Windows gives the ability to run a program on low and critical power level notifications, with adjustable power level triggers.
The most important factor with this idea is that the host server is able to communicate and send the script to the other server, in my current setup both servers are connected to the main network switch that does not have battery backup, meaning that during a power outage the servers will be unable to communicate and therefore unable to shut down safely.
The simple solution was to introduce another switch close to the servers that has power provided by the UPS, for this I chose a NetgearProsafe GS105 and connected both servers to it, with an uplink to the main switch. This also has the advantage of removing traffic away from the main hub when backups between servers take place.
With the servers connected via a backed up power source, it is time to create the shutdown command. On the host server connected to the signal of the UPS, create a .bat file using Notepad with the following line:
shutdown /s /f /m \\MACHINENAME /t 10 /c “Battery Backup Low”
This script tells the computer MACHINENAME to force a shut down in 10 seconds regardless of who is logged in, for those that are the message “Battery Backup Low” will be displayed. The script was then saved to the Windows directory to help avoid accidental deletion.
From the host server, open the power settings from the Control Panel, on the Alarms tab choose Alarm Action on the Low battery alarm field. Check the Run program box and choose the .bat file created to run on the low battery alarm. I chose the Low power instead of Critical to allow the other server to shut down as the Critical would be reserved for the host server itself to shut down.
For testing I chose to put the alarm settings pretty high, which makes the process quicker and also allows more time for a safe shutdown when on battery power. Apart from that the only way to test is to kill the power from the wall and see what happens, look for the other server setting down first as it will hit the Low battery first, then wait for the host server to shut down later. Expect the host server to last a little longer than expected as with the other server shut down, the battery life doubles on two identical machines when one is off.