User Rating: 4 / 5

Star Active Star Active Star Active Star Active Star Inactive

So, if you are a lucky one of having a FusionPBX VoIP cluster and you are sort of paranoid about the availability of your service, you may think about the ultimate countermeasure to mitigate an unavailability risk. Your answer is the deployment of a DRP.

A Disaster Recovery Plan is more than just having an emergency server. But in this article, I will describe just the technical part of deploying this emergency server.

I always deploy my FusionPBX Clusters with a MariaDB Galera cluster on the back. Then, I will write about it.

Preparing your Galera Clusters

Install the following script. I recommend you to put it on /usr/local/bin/

now=$(date +%Y%m%d)
rm -f /tmp/fusionpbx-*-${now}.sql
tables=$(mysql -N -s fusionpbx -e 'show tables')
for t in $tables; do
       if [[ " ${exclude_tables[@]} " =~ " ${t} " ]]; then
               # whatever you want to do when arr contains value
               # echo "mysqldump fusionpbx $t > $f"
               mysqldump --no-data fusionpbx $t > $f

       if [[ ! " ${exclude_tables[@]} " =~ " ${t} " ]]; then
               #echo "mysqldump --no-data fusionpbx $t > $f"
               mysqldump fusionpbx $t > $f

pushd /tmp
tar -cjf $tar fusionpbx-*-${now}.sql

After that, create a passwordless SSH key in the database emergency server and import in your Galera nodes.

Prepare the Database Emergency Server

Put the following script, I recommend under /usr/local/bin/

servers=(db_node1 db_node2)
now=$(date +%Y%m%d)

for i in "${servers[@]}"; do
       echo Trying ${i}
       ssh root@${i} /usr/local/bin/
       if [ $? -ne 0 ]; then
               echo  'Connected'
               scp root@${i}:${tar} /tmp
               pushd /tmp
               tar -jxf ${tar}
               mysqladmin -f drop fusionpbx
               mysqladmin -f drop freeswitch
               mysqladmin -f create fusionpbx
               mysqladmin -f create freeswitch
               for j in $(ls fusionpbx-*.sql); do
                       mysql fusionpbx < $j
               mysql -e 'grant all privileges on fusionpbx.* to fusionpbx@"%" identified by "c4rl0s3l4rt1st4"'
               mysql -e 'grant all privileges on freeswitch.* to fusionpbx@"%" identified by "c4rl0s3l4rt1st4"'
               mysql -e 'flush privileges'


  • Servers are accessible using the root user
  • SSH listen on the port 22/tcp
  • The emergency database server can do a direct SSH to the Galera nodes
  • MariaDB password for FusionPBX is the default in my RPM's
  • Bzip2 is installed on the emergency server

Modify the scripts to fit your need. Good luck!

blog comments powered by Disqus