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.
Install the following script. I recommend you to put it on /usr/local/bin/backup.sh
#!/bin/sh
now=$(date +%Y%m%d)
rm -f /tmp/fusionpbx-*-${now}.sql
tables=$(mysql -N -s fusionpbx -e 'show tables')
exclude_tables=(v_xml_cdr)
for t in $tables; do
f="/tmp/fusionpbx-${t}-${now}.sql"
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
fi
if [[ ! " ${exclude_tables[@]} " =~ " ${t} " ]]; then
#echo "mysqldump --no-data fusionpbx $t > $f"
mysqldump fusionpbx $t > $f
fi
done
tar="fusionpbx-${now}.tar.bz2"
pushd /tmp
tar -cjf $tar fusionpbx-*-${now}.sql
popd
After that, create a passwordless SSH key in the database emergency server and import in your Galera nodes.
Put the following script, I recommend under /usr/local/bin/pull.sh
#!/bin/bash
servers=(db_node1 db_node2)
now=$(date +%Y%m%d)
for i in "${servers[@]}"; do
echo Trying ${i}
ssh root@${i} /usr/local/bin/backup.sh
if [ $? -ne 0 ]; then
continue
else
echo 'Connected'
tar="/tmp/fusionpbx-${now}.tar.bz2"
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
done
popd
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'
break
fi
done
Modify the scripts to fit your need. Good luck!
blog comments powered by DisqusMost Read Posts in Technology
About
Read about IT, Migration, Business, Money, Marketing and other subjects.
Some subjects: FusionPBX, FreeSWITCH, Linux, Security, Canada, Cryptocurrency, Trading.