Updating VICIdial Servers

October 14th, 2020 | by chase
Updating VICIdial Servers

Here’s a great write-up by Anwer covering backing up and restoring an old out-of-date version of VICIdial to the latest version

Suppose you need to migrate or duplicate Vicidial data (campaigns, leads, phones and so on) from one Vicibox server to another. In case two Vicidial boxes of the same versions the process will be simpler. In case the source server has older Vicibox version than the destination one you will have to perform additional steps to get the destination server working.

To simply start with, the goal here is to upgrade DB and Frontend. This is a pretty old system using asterisk 1.8.

Always start with upgrading the DB schema first.

Login to Old Server MariaDB/Mysql command prompt and enter following query to find out current schema version.

MariaDB> use asterisk;MariaDB [asterisk]> SELECT db_schema_version FROM system_settings;+-------------------+| db_schema_version |+-------------------+| 1404 |+-------------------+1 row in set (0.00 sec)

Next, go to /usr/src/astguiclient/trunk/extras. You will find there files named as upgrade_X.XX.sql. As below image. If you dont these files, or not the updated ones (less files), you can always copy them from your new system to old system.

upgrade_2.14.sql is the latest at the time of writing

Before running any of these files, you have to open each file and check where our 1404 schema version is listed. Once we found that file we will first execute that file and then we will move to the next file. We will execute each file till we have upgraded our DB schema to the latest version.

# vi upgrade_2.12.sql
1404 is found under upgrade_2.12.sql file

We will first run upgrade_2.12.sql and than the next file which is upgrade_2.14.sql to complete the schema upgrade process.

# mysql -u root -f asterisk < /usr/src/astguiclient/trunk/extras/upgrade_2.12.sql# mysql -u root -f asterisk < /usr/src/astguiclient/trunk/extras/upgrade_2.14.sql

NOTE: Please make sure you are running the correct .sql file depending upon the schema version you have. If you have older schema than start from that one and than all newer files.

Confirm your current database schema version again and make sure it’s been upgraded.

MariaDB [asterisk]> SELECT db_schema_version FROM system_settings;+-------------------+| db_schema_version |+-------------------+| 1608 |+-------------------+1 row in set (0.00 sec)

Now we have latest schema version. Now vicidial is ready to be backed up with all the data, conf files, recordings etc.

For Vicidial Backup we need to run /usr/share/astguiclient/ADMIN_backup.pl script that has the following options:

# /usr/share/astguiclient/ADMIN_backup.pl --helpallowed run time options:[--db-only] = only backup the database[--db-settings-only] = only backup the database without leads, logs, servers or phones[--db-without-logs] = do not backup the log tables in the database[--db-without-archives] = do not backup the archive tables in the database[--db-remote] = database is not on this server, use --host flag when backing it up[--dbs-selected=X] = backup only selected databases, default uses conf file db onlyto backup databases X and Y, use X---Y, can use --ALL-- for all dbs on serveryou can use --ALLNS-- for all non-mysql dbs(will ignore 'test', 'mysql','information_schema')This feature will NOT work with '--db_raw_files_copy' option[--conf-only] = only backup the asterisk conf files[--without-db] = do not backup the database[--without-conf] = do not backup the conf files[--without-web] = do not backup web files[--without-sounds] = do not backup asterisk sounds[--without-voicemail] = do not backup asterisk voicemail[--without-crontab] = do not backup crontab[--ftp-transfer] = Transfer backup to the 'REPORTS' FTP server[--ftp-server=XXXXXXXX] = OVERRIDE FTP server to send file to[--ftp-login=XXXXXXXX] = OVERRIDE FTP user[--ftp-pass=XXXXXXXX] = OVERRIDE FTP pass[--ftp-dir=XXXXXXXX] = OVERRIDE remote FTP server directory to post files to[--debugX] = super debug[--debug] = debug[--test] = test[--db_raw_files_copy] = if set the backup won't be a mysql dump. It will tar the /var/lib/mysql folder. WARNING, THIS OPTION WILL STOP THE MYSQL SERVER![--archive_path=/PATH/FROM/ROOT] = absolute path to store the resulting backup

There are many different options that you can play with depending upon the type of backup you are looking for. Right now we need to create a Full Vicidial Backup.

# /usr/share/astguiclient/ADMIN_backup.pl --archive_path=/root ----- Archive path set to /root -----  ----- Mysql dump -----ERROR 144 - Table 'vicidial_daily_max_stats' is marked as crashed and last (automatic?) repair failed

NOTE: If you are seeing some error after running backup script, like I faced above. Go to your database folder, stop mysql servce and run following command:

# service mysql stop# cd /var/lib/mysql/asterisk# myisamchk -r vicidial_daily_max_stats

If that doesn’t work, you can try:

# myisamchk -r -v -f vicidial_daily_max_stats# service mysql start

Running the backup script again.

# /usr/share/astguiclient/ADMIN_backup.pl --archive_path=/root ----- Archive path set to /root -----  ----- Mysql dump -----/bin/tar: Removing leading `/' from member names/bin/tar: Removing leading `/' from member names/bin/tar: Removing leading `/' from member names/bin/tar: Removing leading `/' from member names/bin/tar: Removing leading `/' from member names/bin/tar: Removing leading `/' from member names/bin/tar: Removing leading `/' from member namesscript execution time in seconds: 48     minutes: 0.8

Now everything went successfully without any error.

The result will be a compressed file with database dump and configuration files in their respective paths as at /root directory. Where is your Old Vicidial Server IP Address.

Now transfer this backup file to the destination server. Most probably that will be a New Vicibox Installtion.

scp /root/ root@

Now on the destination server navigate to / folder and extract the Vicidial backup archive:

# tar -zxvf

Inside the main archive there will be separate archives for different parts of Vicidial system:

# ls -l /[...]

In tar archives config files are packed in their respective paths so in order restore Vicidial configuration files just unpack the .tar archives:

# tar -xvf *.tarOR# tar each file separately if there is some error in above file liketar -xvf -xvf

Now extract and restore Vicidial database dump on new server:

# tar -zxvf mysql -u root asterisk <

NOTE: It will overwrite the existing DB in the new system. As while installation vicibox DB named asterisk is also created with default settings.


# mysqlMariaDB > DROP DATABASE asterisk;MariaDB > CREATE DATABASE asterisk;MariaDB > exit;# mysql -u root asterisk <

NOTE: Above step will not overwrite the DB as we did earlier, but it will delete the asterisk DB from newly created vicibox server and then create a new blank DB with name “asterisk”. and then restore mysql dump (created earlier) into that database(asterisk).

At this point you have configuration files and database from the old server applied on the new one. We must change IP addresses in all configuration files and in database before we can use the new server if the new server has different IP. If New Server IP is same (in sense as you have switched off Old Server after taking backup and switch on new server which has same IP) as OLD Server IP than there is no need to run below script.

To change IP address in all Vicidial configuration files and database run:

# /usr/share/astguiclient/ADMIN_update_server_ip.plPrevious astGUIclient configuration file found at: /etc/astguiclient.conf Would you like to use interactive mode (y/n): [y] STARTING SERVER IP ADDRESS CHANGE FOR VICIDIAL... Old server IP address or press enter for default: [] server IP address or press enter for default: []   old server_ip:  new server_ip: Are these settings correct?(y/n): [y]Writing change to astguiclient.conf file: /etc/astguiclient.conf STARTING DATABASE TABLES UPDATES PHASE...  Updating servers table...     |0E0|UPDATE servers SET server_ip='' where server_ip='';|[...]

This script is interactive and will guide you through the process.
Make sure there are no errors in the script’s output.
Now reboot your server and check functionality!

Now you have to set the correct Asterisk verison under Admin > Servers, on the new server. Because as we have restored the backup from older server which was running Asterisk 1.8, so the same settings will be reflected under Admin > Server > Asterisk Version which needs to be rectified.

Correct Asterisk version can be obtained by:

# asterisk -rx "core show version"Asterisk 13.34.0-vici built by abuild @ lamb70 on a x86_64 running Linux on 2020-09-27 11:50:31 UTC
Set this under Admin > Server > Asterisk Version and Click Submit

Source: https://anwer.home.blog/2020/10/14/backup-restore-old-vicidial/

Leave a Reply

Your email address will not be published. Required fields are marked *