I have created a warm backup server using the guide in the Wiki. I have my main PBX plugged in to a Cyberpower 1350VA UPS via a USB. This shuts down the main PBX fine, but is there a way for it to also shut down the warm spare?
Hi,
You can run a post backup hook. It is a script that will ssh to the backup server as root and send a poweroff
command.
Why do you want to shutdown your backup server anyway?
Thank you,
Daniel Friedman
Trixton LTD.
I would like to shut it down gracefully in the event of a full power failure to protect it.
How would I create the post backup hook? Iâve never done anything like that before.
Traditionally one could write an init script that would in effect exec:-
ssh the_other_server âshutdown -h nowâ
if the shutdown was called by the UPS, this would need to be called before the network was stopped, and depends on what you are using for init, âsystemdâ or âsystem Vâ and what run-level your system calls on shutdown.
Hi,
Just create a bash script similar to this (I am assuming that you are authenticated by a certificate):
#!/bin/bash
function shutdown_backup_server () {
ssh root@backup_server.com -t "poweroff"
}
shutdown_backup_server
Please be advised that if you will use this script as a post backup hook, it will shutdown the backup server every time. If you want to shutdown your backup server just in a power failure, you can run this script manually from your production server.
Thank you,
Daniel Friedman
Trixton LTD.
Being that this is a âpost backupâ script that it will shutdown the warm spare after each backup? If thatâs the case, thatâs not really what Iâm looking for.
Hi,
If you had read my answer again, you probably would have noticed that I have suggested to run this script manually in a power down situation.
Thank you,
Daniel Friedman
Trixton LTD.
Thatâs why I suggest the init script route, it will be run whenever your system is âcalled downâ including a usb UPS instigated one. It requires no âmanualâ intervention, which would be absolutely necessary in this use case.
Hi,
Yes, I agree with @dicko. You can take my bash script and run it with your UPS software in a power down failure. Just do not forget to give it execution rights (chmod +x script_name.sh
)
Thank you,
Daniel Friedman
Trixton LTD.
Manually running it is not an option. The power could go out when these are unattended.
Iâll look into the other option.
Thanks
For quick and dirty, and if these devices are like most (APC cpome to mind) , somewhere in the software install location will be a script called shutdown.sh or something similar, it is probably a good idea to find it and add the
ssh the_other_server âshutdown -h nowâ
to it before it calls shutdown locally. (You will need âpassword lessâ ssh access to the other server.)
I think you just want to use the (already existing) UPS configuration in Sysadmin.
If you have a look at the documentation, youâll see that you can add a file /etc/apcupsd/doshutdown that will do âthingsâ when the UPS says its time to shut down.
If sysadmin can run on your machine (mine canât, and it is not open source and this is in âgeneral helpâ) and the device supports apcupsd, (not guaranteed)
This sounds like the best solution, but my UPS is a Cyberpower, not APC. Will it still work with Cyberpower? It seems like that documentation is for APC.
Many times the chinese stuff is derivative or just a straight copy, look in the files that where installed somewhere to handle the usb connection, I am sure you will find a shell script that does what I suggest. Edit it . . .
https://www.google.com.au/search?q=cyberpower+apcupsd
Suggests it will
Thanks for the help guys. Iâve read through that link and determined this is too far above my head for now. I may visit it later.
Thanks!
Thatâs where consulting can help you, I suggest you start with