FreePBX Backup and Restore

Question ID : 320
Created on 2013-09-19 at 10:04 AM
Author : Guru Corner [support@guru-corner.com]

Online URL : http://kb.guru-corner.com/question.php?ID=320



Your PBX includes a number of pre-defined backup templates that backup selected components of a PBX installation.

Icon

The file "amportal.conf" does not need to be backed up – it is generated from the configuration database automatically

About backup storage locations

 

Backup storage destinations can be viewed and edited by clicking "Servers" on the right.

There are two default disk storage locations for backup files.

Additional locations can be created to send backups to an e-mail account, a remote FTP server, a remote server using SFTP, or a remote MySQL server. These options are used for sending backups to a different server or site, or for setting up a warm standby FreePBX system.

About the default "Default backup" backup

Access the Backup and Restore module

FreePBX 2.10

Backup and Restore module initial configuration

Set the From e-mail address

This is the e-mail address the the backup module will send e-mail from if configured to send backups to an e-mail address. By default, the backup module is not configured to do this, and this from e-mail address is left blank.

FreePBX 2.10

Creating a backup job

Example: Configure a full backup

This is a full backup of all PBX configuration and user audio data, done once a day at midnight.

The backup will appear on the small menu on the right.

Test the backup using the manual backup process, below.

Example: Configure a voicemail-only backup

This is a second scheduled job that backs up only the voicemail at noon each day. This backup augments the backup above by providing some protection from users mistakenly deleting a voicemail they received the same day, which will not be in the nightly full daily backup yet.

The backup will appear on the small menu on the right.

Test the backup using the manual backup process, below.

Manual backup test

Backup verification

tar --list --file /var/spool/asterisk/backup/fullbackup/20130503-164647-1367614007-1697135908.tgz
./
./etc/
./etc/asterisk/
./etc/asterisk/queues_general_additional.conf
./etc/asterisk/sip_notify_custom.conf
./etc/asterisk/chan_dahdi.conf.template
...
./etc/dahdi/
./etc/dahdi/system.conf
./etc/dahdi/genconf_parameters
./etc/dahdi/init.conf
./etc/dahdi/modules
./etc/freepbx.conf
./mysql-4.sql
./mysql-3.sql
./.lock
./manifest
./var/
./var/lib/
./var/lib/asterisk/
./var/lib/asterisk/sounds/
./var/lib/asterisk/sounds/custom/
...
./var/www/
./var/www/html/
./var/www/html/robots.txt
./var/www/html/index.html
./var/www/html/admin/
./var/www/html/admin/images/
...
./usr/sbin/warnquota
./usr/sbin/pvscan
./astdb
cd /tmp
tar xvf /var/spool/asterisk/backup/fullbackup/20130503-164647-1367614007-1697135908.tgz ./astdb
vi /tmp/astdb
# the contents will be a solid block of text containing strings like AMPUSER and EXTENSION
rm /tmp/astdb

Restore a backup

Icon

Ensure the exact same version of FreePBX Distro and same version of the Backup & Restore module is installed on the target restore system as used on the backed-up system if at all possible.

Monitoring of backups

Configuring e-mail notifications

The user asterisk will, by default, get an e-mail containing cron job output from each backup, indicating if the backup succeeded or failed. To get these, edit /etc/aliases and ensure that the user asterisk has e-mail directed to a monitored e-mail address.

Configure e-mail redirection to a monitored e-mail account

vi /etc/aliases
...
# Customization: all of the "asterisk" user's mail should be directed to the local root user
asterisk: root
# Customization: all of the "root" user's mail should be directed to a monitored e-mail address (note: redirection ordering matters; the root user redirection should be last in the file)
root: myemailaddress@domain.org
Icon

It also works just to redirect e-mail to the asterisk user directly to an external e-mail address. However, it is a recommended best practice to direct all other users' e-mail first to the root user, and then ensure e-mail to the root user is sent to a human being. This will ensure that e-mails sent by other programs on a FreePBX server which send to root by default (such as mdadm RAID monitoring) will also be seen.

newaliases
echo "This is a test e-mail to the local asterisk account. It should go to the actual monitored e-mail address through the /etc/aliases file." | mail -s "E-mail test to local asterisk account" asterisk; tail -f /var/log/maillog | grep "status="
 
# expected result (two successful sends, one to the local account and one to the external e-mail address)
May  3 17:38:16 ... postfix/local[8423]: BB4CB1D61804: to=, orig_to=, relay=local, delay=0.08, delays=0.06/0.01/0/0.01, dsn=2.0.0, status=sent (forwarded as C43981D6176C)
May  3 17:38:16 ... postfix/smtp[8424]: C43981D6176C: to=, orig_to=, relay=..., delay=0.07, delays=0.01/0.01/0.01/0.04, dsn=2.0.0, status=sent (250 Message accepted for delivery)

Troubleshooting

Verify asterisk user backup cron jobs

The web user interface creates cron jobs for the user asterisk that perform the actual backups. It is helpful when troubleshooting to confirm these cron jobs are present.

crontab -u asterisk -l
...
@monthly /var/lib/asterisk/bin/backup.php --id=1


Back to Original Question