Backup

Periodic backup

A backup of the database and the data are launched every day with a logrotate task. It is run at 06:25 a.m. and backups are kept for 7 days.

Logrotate task:

/etc/logrotate.d/xivo-backup

Logrotate cron:

/etc/cron.daily/logrotate

Retrieve the backup

You can retrieve the backup from the web-interface in Services ‣ IPBX ‣ IPBX Configuration ‣ Backup Files page.

Otherwise, with shell access, you can retrieve them in /var/backups/xivo. In this directory you will find db.tgz and data.tgz files for the database and data backups.

Backup scripts:

/usr/sbin/xivo-backup

Backup location:

/var/backups/xivo

What is actually backed-up?

Data

Here is the list of folders and files that are backed-up:

  • /etc/asterisk/

  • /etc/consul/

  • /etc/crontab

  • /etc/dahdi/

  • /etc/dhcp/ ⚠️️ This will overwrite the network configuration when the backup is restored ⚠

  • /etc/hostname ⚠️️ This will overwrite the network configuration when the backup is restored ⚠

  • /etc/hosts ⚠️️ This will overwrite the network configuration when the backup is restored ⚠

  • /etc/ldap/

  • /etc/network/if-up.d/xivo-routes

  • /etc/network/interfaces ⚠️️ This includes the host IP address / netmask and will overwrite the network configuration when the backup is restored ⚠ ️

  • /etc/ntp.conf

  • /etc/profile.d/xivo_uuid.sh

  • /etc/resolv.conf ⚠️️ This will overwrite the network configuration when the backup is restored ⚠

  • /etc/ssl/

  • /etc/systemd/

  • /etc/wanpipe/

  • /etc/xivo-agentd/

  • /etc/xivo-agid/

  • /etc/xivo-amid/

  • /etc/xivo-auth/

  • /etc/xivo-call-logd/

  • /etc/xivo-confd/

  • /etc/xivo-confgend-client/

  • /etc/xivo-ctid/

  • /etc/xivo-dird/

  • /etc/xivo-dird-phoned/

  • /etc/xivo-dxtora/

  • /etc/xivo-purge-db/

  • /etc/xivo/

  • /etc/xivo-xuc.conf

  • /usr/local/bin/

  • /usr/local/sbin/

  • /usr/share/xivo/XIVO-VERSION

  • /var/lib/asterisk/

  • /var/lib/consul/

  • /var/lib/xivo-provd/

  • /var/lib/xivo/

  • /var/log/asterisk/

  • /var/spool/asterisk/

  • /var/spool/cron/crontabs/

  • /etc/docker/

  • /etc/fail2ban/

  • /var/lib/postgresql/11/main/*.conf

  • /var/lib/postgresql/11/main/conf.d/*.conf

The following files/folders are excluded from this backup:

  • folders:

    • /var/lib/consul/checks

    • /var/lib/consul/raft

    • /var/lib/consul/serf

    • /var/lib/consul/services

    • /var/lib/xivo-provd/plugins/*/var/cache/*

    • /var/spool/asterisk/monitor/

    • /var/spool/asterisk/meetme/

  • files

    • /var/lib/xivo-provd/plugins/xivo-polycom*/var/tftpboot/*.ld

  • log files, coredump files

  • audio recordings

  • and, files greater than 10 MiB or folders containing more than 100 files if they belong to one of these folders:

    • /var/lib/xivo/sounds/

    • /var/lib/asterisk/sounds/custom/

    • /var/lib/asterisk/moh/

    • /var/spool/asterisk/voicemail/

    • /var/spool/asterisk/monitor/

Database

The database asterisk from PostgreSQL is backed up. This include almost everything that is configured via the web interface.

Creating backup files manually

Warning

A backup file may take a lot of space on the disk. You should check the free space on the partition before creating one.

Database

You can manually create a database backup file named db-manual.tgz in /var/tmp by issuing the following commands:

xivo-backup db /var/tmp/db-manual

Files

You can manually create a data backup file named data-manual.tgz in /var/tmp by issuing the following commands:

xivo-backup data /var/tmp/data-manual

Restore

Introduction

A backup of both the configuration files and the database used by a XiVO installation is done automatically every day. These backups are created in the /var/backups/xivo directory and are kept for 7 days.

Warning

A XiVO backup includes the entirety of the original machine’s network configuration : it WILL overwrite any present network settings when you restore it. Remember to change those settings back if required before restarting network services or the machine itself, especially if you do not have physical or console access!

Limitations

  • You must restore a backup on the same version of XiVO that was backed up (though the architecture – i386 or amd64 – may differ)

  • You must restore a backup on a machine with the same hostname and IP address

  • Be aware that this procedure applies only to XiVO >= 14.08

  • XiVO CC configuration files are not backed up. Follow Manual XiVO PBX configuration to restore them.

Before Restoring the System

Warning

Before restoring a XiVO on a fresh install you have to setup XiVO using the wizard (see Running the Wizard section).

Stop monit and all the xivo services:

xivo-service stop

Before restoring the database, all other services connected to it (XiVO CC, MDS) must be stopped also. You can list active connections: sudo -u postgres psql -c "SELECT * FROM pg_stat_activity WHERE pid <> pg_backend_pid()"

If you want to restore XiVO < 2017.06 that was configured for XiVO CC, you must create PostgreSQL user stats before restoring the database. See Creating user stats.

Restoring System Files

System files are stored in the data.tgz file located in the /var/backups/xivo directory.

This file contains for example, voicemail files, musics, voice guides, phone sets firmwares, provisioning server configuration database.

To restore the file

tar xvfp /var/backups/xivo/data.tgz -C /

Restoring the Database

Warning

  • This will destroy all the current data in your database.

  • You have to check the free space on your system partition before extracting the backups.

Database backups are created as db.tgz files in the /var/backups/xivo directory. These tarballs contains a dump of the database used in XiVO.

In this example, we’ll restore the database from a backup file named db.tgz placed in the home directory of root.

First, extract the content of the db.tgz file into the /var/tmp directory and go inside the newly created directory:

tar xvf db.tgz -C /var/tmp
cd /var/tmp/pg-backup

Drop the asterisk database and restore it with the one from the backup:

sudo -u postgres dropdb asterisk
sudo -u postgres pg_restore -C -d postgres asterisk-*.dump

To finalize the restore, see After Restoring The System.

Troubleshooting

When restoring the database, if you encounter problems related to the system locale, see PostgreSQL localization errors.

Alternative: Restoring and Keeping System Configuration

System configuration like network interfaces is stored in the database. It is possible to keep this configuration and only restore xivo data.

Rename the asterisk database to asterisk_previous:

sudo -u postgres psql -c 'ALTER DATABASE asterisk RENAME TO asterisk_previous'

Restore the asterisk database from the backup:

sudo -u postgres pg_restore -C -d postgres asterisk-*.dump

Restore the system configuration tables from the asterisk_previous database:

sudo -u postgres pg_dump -c -t dhcp -t netiface -t resolvconf asterisk_previous | sudo -u postgres psql asterisk

Drop the asterisk_previous database:

sudo -u postgres dropdb asterisk_previous

Warning

Restoring the data.tgz file also restores system files such as host hostname, network interfaces, etc. You will need to reapply the network configuration if you restore the data.tgz file.

After Restoring The System

Resynchronize the xivo-auth keys:

xivo-update-keys

Update systemd runtime configuration:

source /etc/profile.d/xivo_uuid.sh
systemctl set-environment XIVO_UUID=$XIVO_UUID
systemctl daemon-reload

Restart the services you stopped in the first step:

xivo-service start

You may also reboot the system. Remember that the network settings were overwritten by the backed up settings, check and fix if necessary before rebooting!