PBX

PBX — Backup and Restore Procedures

What Needs to Be Backed Up

  1. MariaDB database (asterisk_rt) — All PJSIP config, tenants, extensions, DIDs, CDRs, dialplan, voicemail metadata.
  2. Voicemail audio/var/spool/asterisk/voicemail/
  3. Call recordings/var/spool/asterisk/monitor/

Application code and system config are managed via Git and the installer package — only data files need daily backup.

Automated Nightly Backup

Backups run nightly at 2:00 AM via the backup worker. Configure in System → Backups:

  • Destination — Local disk, S3-compatible (AWS S3, Wasabi, Backblaze B2), or SFTP.
  • Retention — 7 daily, 4 weekly, 3 monthly (default).
  • Encryption — AES-256 at rest. Store the encryption key separately.

Manual Database Backup

mysqldump -u root asterisk_rt | gzip > /backup/asterisk_rt_$(date +%Y%m%d).sql.gz

Always verify the dump is non-zero before considering it successful.

Database Restore

  1. Stop Asterisk: systemctl stop asterisk
  2. Recreate the database:
    mysql -u root -e "DROP DATABASE asterisk_rt; CREATE DATABASE asterisk_rt CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
  3. Restore: zcat /backup/asterisk_rt_20260101.sql.gz | mysql -u root asterisk_rt
  4. Start Asterisk: systemctl start asterisk
  5. Verify: asterisk -rx "pjsip show endpoints"

Restoring Voicemail and Recordings

rsync -av /backup/voicemail/ /var/spool/asterisk/voicemail/
rsync -av /backup/monitor/ /var/spool/asterisk/monitor/
chown -R asterisk:asterisk /var/spool/asterisk/

Testing Restores (Monthly)

Restore to a non-production environment and verify: extensions register, voicemail messages are present, CDRs are intact, and the admin portal loads correctly. A backup never tested is not a reliable backup.