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.
Before you start
Section titled “Before you start”- 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.
Step 1: Schedule the backup
Section titled “Step 1: Schedule the backup”-
Open System Management → System Parameters.
-
Click Backup, Data Retention.
-
Under Backup, set the fields:
Field Value Notes Schedule DailyNever(default) turns the backup off.WeeklyandMonthlyare also availableStart Time Your off-peak time, for example 04:30Half-hour steps, in the time zone of the server Dump Format SQL Dump (Text)See the formats below Generations 7How many backups are kept on the switch, 1to15. Older ones are deletedCompression gzipbzip2gives smaller files but takes longer;no compressionis also available -
Select Notify on Success if you want an e-mail after every successful backup. The option is shown in the root environment only.
-
Click Save.
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.
Step 2: Check the backup files
Section titled “Step 2: Check the backup files”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:
- Prepare the remote server and a folder for the backups.
- Send FlySIP support the address, protocol, credentials and folder.
- 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.
Step 4: Test it
Section titled “Step 4: Test it”- Wait for the first scheduled run, or ask support to start one.
- Check
/var/log/backup.log, or the success e-mail, forbackup procedure has been finished successfully. - Check that the files have arrived on the remote server and that their size is plausible.
Restore after a total loss
Section titled “Restore after a total loss”If the switch is lost and there is no standby server:
- Install the switch from scratch with the FlySIP installation image.
- Contact FlySIP support to activate the new server, and give them the location of the latest backup files on your remote server.
- Support restores the database from the backup.
What’s next
Section titled “What’s next”- Archive and purge old CDRs: the Data Retention half of the same screen.
- System parameters: all settings of an environment.
- Hardware requirements: the separate disks recommended for backups and logs.