How to backup settings of users in GUI

From VoIPmonitor.org
Revision as of 19:57, 23 November 2015 by Petr.halounek (talk | contribs)
Jump to navigation Jump to search

Run in bash following commandline to dump only users settings to /tmp/settings.sql

mydb='voipmonitor'; mysql ${mydb} -Ne "show tables from voipmonitor where \
  \`Tables_in_${mydb}\` LIKE 'alerts_%' OR \
  \`Tables_in_${mydb}\` LIKE 'cdr%' AND \
  \`Tables_in_${mydb}\` NOT LIKE 'cdr_custom_headers' OR \
  \`Tables_in_${mydb}\` LIKE '%country%' OR \
  \`Tables_in_${mydb}\` LIKE 'register%' OR \
  \`Tables_in_${mydb}\` LIKE 'cache_number_location' OR \
  \`Tables_in_${mydb}\` LIKE 'contenttype' OR \
  \`Tables_in_${mydb}\` LIKE 'files' OR \
  \`Tables_in_${mydb}\` LIKE 'live_packet' OR \
  \`Tables_in_${mydb}\` LIKE 'message' OR \
  \`Tables_in_${mydb}\` LIKE 'rtp_stat' OR \
  \`Tables_in_${mydb}\` LIKE 'system' \
  "| sed -e "s/^/--ignore-table=${mydb}./" |xargs mysqldump -c --skip-triggers --skip-add-locks --no-create-info ${mydb} > /tmp/settings.sql


If you wish to restore dumpfile, with with creation of a new db:

mysqladmin create voipmonitor

Let your latest sensor, creates new tables needed for voipmonitor service:

/etc/init.d/voipmonitor restart

Let your GUI creates tables needed for GUI, Just login to web GUI with your browser (If you are already logged in, logout first and then 'relogin'. (default login is admin / admin)

http://voipmonitor_IP

Remove data from tables that are customizable by users/admins (because these data was dumped).

mysql voipmonitor -e "SET FOREIGN_KEY_CHECKS = 0; TRUNCATE table tracker_category; TRUNCATE table tracker_priority; TRUNCATE table tracker_status; SET FOREIGN_KEY_CHECKS = 1;" 

Restore settings

mysql voipmonitor < /tmp/settings.sql


            1. Other way
mydb='voipmonitor'; mysqldump -c --no-create-info ${mydb} \
 --ignore-table=${mydb}.alerts_sended \
 --ignore-table=${mydb}.cache_number_location \
 --ignore-table=${mydb}.cdr \
 --ignore-table=${mydb}.cdr_dtmf \
 --ignore-table=${mydb}.cdr_next \
 --ignore-table=${mydb}.cdr_proxy \
 --ignore-table=${mydb}.cdr_reason \
 --ignore-table=${mydb}.cdr_rtp \
 --ignore-table=${mydb}.cdr_sip_request \
 --ignore-table=${mydb}.cdr_sip_response \
 --ignore-table=${mydb}.cdr_siphistory \
 --ignore-table=${mydb}.cdr_sipresp \
 --ignore-table=${mydb}.cdr_tarpart \
 --ignore-table=${mydb}.cdr_ua \
 --ignore-table=${mydb}.contenttype \
 --ignore-table=${mydb}.files \
 --ignore-table=${mydb}.livepacket \
 --ignore-table=${mydb}.message \
 --ignore-table=${mydb}.register \
 --ignore-table=${mydb}.register_failed \
 --ignore-table=${mydb}.register_state \
 --ignore-table=${mydb}.rtp_stat > /tmp/settings.sql

But this not work when alerts backup table(s) exists. (You need to manualy add --ignore-table=voipmonitor.alerts__bck-2015-10-08 for each alerts__bck tables you have in db)