Backup fop2 using FreePBX 15 Backup Module
Using the FreePBX 15 Backup module with a couple of scripts you can backup fop2 and all its information with the use of custom files/directories and a couple of scripts.
Within your Backup job, add the following custom files/directories:
Directory: /usr/local/fop2
Directory: /var/www/html/fop2
File: /var/lib/asterisk/astdb.sqlite3
Now create the following Pre-Backup Hook script:
#!/bin/bash
DBUSER=cat /etc/freepbx.conf | sed 's/ //g' | grep AMPDBUSER | tail -n 1 | cut -d\" -f4
DBPASS=cat /etc/freepbx.conf | sed 's/ //g' | grep AMPDBPASS | tail -n 1 | cut -d\" -f4
mysqldump --add-drop-table -u $DBUSER -p$DBPASS asterisk $(mysql -u $DBUSER -p$DBPASS -D asterisk -Bse “SHOW TABLES LIKE ‘fop2%’”) > /usr/local/fop2/fop2_backup.sql
Now create the following Post Restore Hook script:
#!/bin/bash
DBUSER=cat /etc/freepbx.conf | sed 's/ //g' | grep AMPDBUSER | tail -n 1 | cut -d\" -f4
DBPASS=cat /etc/freepbx.conf | sed 's/ //g' | grep AMPDBPASS | tail -n 1 | cut -d\" -f4
mysql -u $DBUSER -p$DBPASS asterisk < /usr/local/fop2/fop2_backup.sql
fwconsole restart
sleep 30
systemctl restart fop2
Notes:
The Pre-backup and Post-restore scripts need to be owned by the Asterisk user (chown asterisk:asterisk /path/to/script/file) and must be executable (chmod +x /path/to/script/file).
My advice would be to place these scripts inside /usr/local/fop2 as they will be included in the backup and therefore move over automatically.
If you a backing up and restoring to a Warm Spare Server, then you want to exclude fop2.lic and fop2_server from the /usr/local/fop2 directory. (Each server should have it’s own fop2_server and licence (plus its own copy of any licence plugs you use)
Other non-fop2 information in the AstDB will be restored.
Restoring will restart FreePBX on the destination server and therefore active calls on that server will be dropped. If you are doing this as part of a warm spare then there will be no calls on that server so this isn't a problem.