Skip to content

Back up the database automatically

The switch can back up its database on a schedule while it keeps processing calls. This tutorial turns on a daily backup, explains the formats, and sets up the copy to a remote server, so that you can restore the switch even if its disk is lost. Allow 15 minutes, plus the time support needs for the remote copy.

  • You have Administrator access to the panel. The backup settings apply to the environment you are logged in to.
  • You know the quietest hour of your traffic. A backup runs online but puts a heavy load on the disk and the database, which can affect call processing.
  • For the remote copy: a server that accepts the files (FTP, TFTP, SFTP or similar) and its address, credentials and folder.
  1. Open System Management → System Parameters.

  2. Click Backup, Data Retention.

  3. Under Backup, set the fields:

    Field Value Notes
    Schedule Daily Never (default) turns the backup off. Weekly and Monthly are also available
    Start Time Your off-peak time, for example 04:30 Half-hour steps, in the time zone of the server
    Dump Format SQL Dump (Text) See the formats below
    Generations 7 How many backups are kept on the switch, 1 to 15. Older ones are deleted
    Compression gzip bzip2 gives smaller files but takes longer; no compression is also available
  4. Select Notify on Success if you want an e-mail after every successful backup. The option is shown in the root environment only.

  5. Click Save.

Screenshot "tutorials/backup-data-retention" has not been generated yet — see scripts/screenshots/screens.yml.

Result: the backup starts within half an hour after Start Time. A weekly or monthly backup runs when the last one is at least a week or a month old, so it keeps the weekday or the day of the month of the first run. If you turn on a weekly backup on a Friday afternoon with Start Time 04:30, it runs every Saturday at 04:30.

The formats differ in how fast and where you can restore them:

Dump Format Restore speed Restore on another database version Size
SQL Dump (Text) Moderate Yes, any version. The safest choice Medium
SQL Dump (Binary) Good Same major version only Small
SQL Dump (TAR) Good; you can pick which tables and data to restore Same major version only Medium
DB Snapshot Fastest Only the exact same version Large

DB Snapshot is available in the root environment only and copies the databases of all environments at once.

Each run writes, in /var/backups/env<N>/ on the switch, where <N> is the number of the environment:

  • one file per database (the main database, balances and CDRs), named env<N>-backup-<database>-<YYYYMMDD> with the extension of the format and the compression, for example .sql.gz;
  • an archive of the environment’s files, named var_env<N>-<YYYYMMDD>.tar.gz.

All backup activity is logged in /var/log/backup.log. A failed backup sends an alert e-mail to the address of the root customer.

Step 3: Copy each backup to a remote server

Section titled “Step 3: Copy each backup to a remote server”

After writing each file, the backup runs the script /var/db/pgsql/ecopy with the full path of the file as its only argument, if the script exists. Exit code 0 means the copy succeeded; any other code is logged as a failure and sends an External copy failed e-mail. A sample script that uploads to a TFTP server is in /home/ssp/scripts/ecopy_tftp.sh.

The script runs on the switch itself, so FlySIP support installs it:

  1. Prepare the remote server and a folder for the backups.
  2. Send FlySIP support the address, protocol, credentials and folder.
  3. Wait for support to confirm that the script is installed.

The switch deletes old backups only from its own disk, after Generations. Rotate the copies on the remote server yourself, for example with a cleanup job that keeps the last 30 days.

  1. Wait for the first scheduled run, or ask support to start one.
  2. Check /var/log/backup.log, or the success e-mail, for backup procedure has been finished successfully.
  3. Check that the files have arrived on the remote server and that their size is plausible.

If the switch is lost and there is no standby server:

  1. Install the switch from scratch with the FlySIP installation image.
  2. Contact FlySIP support to activate the new server, and give them the location of the latest backup files on your remote server.
  3. Support restores the database from the backup.