- Published: Wednesday, 14 September 2011 09:01
Below are my instructions for a simple manual failover solution for Trixbox.
We use two servers at our company.
Overall notes: for this script to work well you should follow THESE instructions to set up SSH with no password.
You may find that some commands are wrapped on the screen, it should be easy to find these lines, just make sure you coorect them if you copy paste.
Primary Server - IP - 10.20.0.5 - 2 NICs one is public facing allowing for remote connections.
Backup Server - IP - 10.20.0.4 - Duplicate of main server, Same model of server
First the Primary Server.
Every Hour the server will run the following backup script. the script will backup the following.
- ETC and VAR folders - These are straight copied to the backup server with the exception of the /etc/sysconfig folder. We do not directly back this up because if we did the backup server would assume the same IP addresses, thus breaking the Primary Server
- MySQL tables - These are backed up to the backup server under the /tmp/mysqlbackups folder, you will need to create this folder.
- It will then invoke a script sitting on the backup server which will restore the MySQL databases on the backup server that were just copied over.
- It will then copy the /etc/sysconfig folder contents to the backup server under the /network-repair-info/ folder
Now the Backup Server
The backup server has two scripts on it.
- Restoremysql - this script is run every hour as part of the primary backup script it will restore the MySQL databases that were copied from the primary server.
- Restore_Server - This script is run only in the event that you need to bring the backup server up as the main.
#!/bin/sh #this script will restore the mysql databases backed up from the main server mysql -u root -ppassw0rd asterisk < /tmp/mysqlbackups/asterisk.sql mysql -u root -ppassw0rd information_schema < /tmp/mysqlbackups/information_schema.sql mysql -u root -ppassw0rd asteriskcdrdb < /tmp/mysqlbackups/asteriskcdrdb.sql mysql -u root -ppassw0rd asteriskrealtime < /tmp/mysqlbackups/asteriskrealtime.sql mysql -u root -ppassw0rd endpoints < /tmp/mysqlbackups/endpoints.sql mysql -u root -ppassw0rd meetme < /tmp/mysqlbackups/meetme.sql mysql -u root -ppassw0rd mysql < /tmp/mysqlbackups/mysql.sql
This script is still under construction. It's goal is to promote the backup server in the case that the primary fails.
#!/bin/sh #This script will bring this server up as the main server #Amportal is not set to start on boot so replace the rc.local file so that it will start on boot mv /etc/rc.d/rc.local.backup /etc/rc.d/rc.local #A iptables line has been added to restrict access to the SIP provider to block registration #this command blocks all traffic help with registration when /sbin/iptables -A OUTPUT -s 188.8.131.52 -j DROP #The below command will unblock the SIP Provider IP /sbin/iptables -D OUTPUT -s 184.108.40.206 -j DROP #now make a backup of the current sysconfig settings tar -cvf /sysconfigbeforebackup.tar /etc/sysconfig/* #now remove all old sysconf info rm -rvf /etc/sysconfig/* #copy current sysconfig info cp -r /network-repair-info/* /etc/sysconfig/ #restart server reboot
And that is it for now. if you see any problems or better ways to do it please leave a comment for all to see!