Project

General

Profile

Backup and recovery

Manual database backup

The system stores the data in a database, hereinafter referred to as DB and in files.

DB consists of 3 databases:
  • config contains configuration data
  • storage contains CDR and other bulk data
  • var contains local temporary data, such as a table of active calls

The most valuable data is contained in the config and storage databases.

config

The config database is stored in the InnoDB format.
The system by default creates a backup of the config database in the form of an SQL dump every 6 hours.
Backups are saved in archives /var/backup/smartswitch.
You have backups for every 6 hours for the last month at any given time.
You may want to use backup in the following cases:

  • irreparable corruption of InnoDB log files due to incorrect system reboot
  • operator error (for example deleting important information)

To restore the config database from backup, use the following instructions (assuming that you want to restore the 010600.tgz archive:

Attention! If you are a Streamco customer, do not perform the following operations yourself!
You can ruin all your data.
Contact technical support!

# sudo -s
# cd /usr/local/smartswith/mysql
# tar zxvf /var/backups/smartswitch/010600.tgz
# mysql
mysql> drop database config;
mysql> create database config;
mysql> exit
# mysql config < 010600/config.sql

You can configure rsync to backup these files to your server.
Install the expect package and add the following script to run periodically on the remote host:

#!/bin/sh

SSH_LOGIN=<your SSH login>
SSH_PASSWORD=<your SSH password>
HOST_IP=<IP address of the server with Smartswitch>
expect -c "spawn rsync -axSRzv $SSH_LOGIN@$HOST_IP:/var/backups/smartswitch ./; expect \"*?assword:*\" {send \"$SSH_PASSWORD\r\"; interact};" 

storage

The storage database is stored in the MyISAM format.
The storage database is not backed up to a local disk due to its large size.
MyISAM is not logged, therefore, in case of incorrect reboots, the entire database can be restored without resorting to backups.
In case of damage, the standard procedure for restoring MyISAM MySQL databases is used (for example, to restore the cdr table):

Attention! If you are a Streamco customer, do not perform the following operations yourself!
You can ruin all your data.
Contact technical support!

mysql> repair table cdr use_frm;

With this command you will restore the cdr table.
Similarly, you can recover any other damaged table.

The system has a script that automatically restores all tables:

/usr/local/bin/smartswitch/repair.sh

Run it to restore the storage database after an incorrect power reboot of the server.

You can also set up replication of this database to another server to maintain a constantly up-to-date backup copy.
In this case, even if the main server completely fails, you are guaranteed to have a snapshot of the database on the server to which you are replicating.
For more information about this feature, see MySQL_Replication.

var

This database does not store important data.
However, it does have the necessary tables and stores the license key.
It is enough to back it up just once (however, you need to make a backup after each update, since the database format usually changes with an update):

# mysqldmp --single-transaction -S /usr/local/smartswitch/mysql_var/mysql.sock var > var.sql

Copy the resulting var.sql somewhere and use the procedure to restore:

Attention! If you are a Streamco customer, do not perform the following operations yourself!
You can cause the entire system to crash.
Contact technical support!

# mysql -S /usr/local/smartswitch/mysql_var/mysql.sock var
mysql> drop database var;
mysql> create database var;
mysql> exit
# mysql -S /usr/local/smartswitch/mysql_var/mysql.sock var < var.sql

Backup and recovery of files

Important files are recordings of telephone conversations.
They are stored in /usr/local/smartswitch/recordings.

You can configure rsync to backup these files to your server.
Install the expect package and add the following script to run periodically on the remote host:

#!/bin/sh

SSH_LOGIN=<your SSH login>
SSH_PASSWORD=<your SSH password>
HOST_IP=<IP address of the server with Smartswitch>
expect -c "spawn rsync -axSRzv $SSH_LOGIN@$HOST_IP:/usr/local/smartswitch/recordings ./; expect \"*?assword:*\" {send \"$SSH_PASSWORD\r\"; interact};" 

Manual file system backup

To backup the file system, use the following procedure:

# mkdir backup
# cd backup
# dump -0 -L -f - / | gzip -9 > root.img.gz
# dump -0 -L -f - /usr | gzip -9 > usr.img.gz
# dump -0 -L -f - /var | gzip -9 > var.img.gz

Transfer the files to your PC.
Let your login be admin, and the server IP address be 192.168.0.1.

# pscp.exe -r admin@192.168.0.1:backup backup

After this, you have snapshots of all file systems on your PC.

To restore from a backup, first install the system from our installation disk, and then transfer the backup to it:

# pscp.exe -r backup admin@192.168.0.1:

Then restore from backup:

# cd backup
# gzip -d root.img.gz | ( cd / ; restore -rf - )
# gzip -d usr.img.gz | ( cd /usr ; restore -rf - )
# gzip -d var.img.gz | ( cd /var ; restore -rf - )

Automatic full system backup

For loaded production systems, the manual backup method is not suitable, since data loss is possible in the interval between the backup and the hardware failure.
To set up automatic backup, our company’s engineers use “MySQL replication”: http://dev.mysql.com/doc/refman/5.0/en/replication.html. together with the use of rsync.
Setting up replication is beyond the scope of this guide.

Русский перевод

Also available in: PDF HTML TXT