Skip to main content

Non-production environment

The UCS license allows the creation of any number of non-production environments (development, test, stage, etc.). These environments are licensed free of charge to the same extent as for production environments.

Data transfer

Settings are usually synchronized from a production to a non-production environment.

The SQL script /etc/ucs/migrate.sql can be used on the target environment, which is automatically called when using the ucs-db-restore command.

BEGIN;
UPDATE config SET val = 'ucs-test.zakaznik.cz' WHERE key = 'HOSTNAME';
UPDATE users SET password = 'plain$ucs';
UPDATE trunks SET host = '10.20.30.40';
UPDATE incoming SET pattern = '222333XXX' WHERE trunk_id = 1;
UPDATE outgoing SET caller_prefix = '+420222333' WHERE trunk_id = 1;
COMMIT;

Data preparation

A DB dump is performed on the production environment. It is then packed into an archive together with the audio files.

#!/bin/bash

cd /
ucs-db-dump -x prod.sql
tar cfz prod.tar.gz \
prod.sql \
var/lib/asterisk/sounds \
var/lib/asterisk/_sounds \
var/lib/asterisk/_moh \
var/lib/asterisk/moh*

Data recovery

On a non-production environment, an archive will be extracted that will overwrite the audio files. Subsequently, UCS is stopped and the database is overwritten with the ucs-db-restore command setting from the production environment. If the /etc/ucs/migrate.sql script exists, then it is automatically called after loading data from prod.sql.

#!/bin/bash

cd /
tar xf prod.tar.gz
ucs-db-restore prod.sql

If retention of test data (e.g. CDRs, recordings, statistics, etc.) is required, then it is also possible to back up the data and restore it again after uploading the production configuration.

#!/bin/bash

cd /
tar xf prod.tar.gz
ucs-db-dump -d data.sql
ucs-db-restore prod.sql
ucs-psql < data.sql