Backup and restore GUI tables: Difference between revisions

From VoIPmonitor.org
Jump to navigation Jump to search
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:


= backup and restore settings script=
= Backup and restore GUI table settings script=
the script is used for peridically restore of settings from proimary db(GUI) host to a backup GUI(db) host. (can be used with migration instance to mirror also GUI settings not only calldata)
the script is used for peridically restore of settings from primary db(GUI) host to a backup GUI(db) host. (can be used with migration instance to mirror also GUI settings not only calldata)




== Requirements ==
== Requirements ==
the script requires to set at least **primaryhost** variable, folders defined by backupfilenameremote and backupfilenamelocal needs to exists on the hosts,
the script requires to set at least variables: primaryhost,backupfilenameremote,backupfilenamelocal
also it is necessary to allow passless access to primary host from secondary host as root and the script needs to be run under root user.
Folders in paths defined in sctipt needs to exists on the hosts, also it is necessary to allow passless access to primary host from secondary host as root and the script needs to be run under root user.
 
The voipmontior GUI on backup host needs to points to backupdb


== Script ==
== Script ==
Line 28: Line 28:
   
   
  #remove the backup file on the primary after copied
  #remove the backup file on the primary after copied
  ssh $primaryhost "rm $backupfilenameremote"
  ssh $primaryhost rm $backupfilenameremote
   
   
  #apply the backup here
  #apply the backup here
Line 38: Line 38:
   rm $backupfilenamelocal
   rm $backupfilenamelocal
  fi
  fi


== Crontab ==
== Crontab ==
I placed it into /etc/crontab with line like following to backup and restore every 30 minutes
Placed following line into /etc/crontab to backup and restore every 30 minutes
  */30 * * * * root /root/voipmonitor/backup_and_restore.sh
  */30 * * * * root /root/voipmonitor/backup_and_restore.sh
Then restart the crontab or send it HUP signall with kill command
Then restart the crontab or send it HUP signall with kill command
== Notes ==
Keep in mind that when GUI on primary is configured to send the emails, after the settings migrated to backup GUI/db it will try to send same emails as well - you should disable the deafult crontab line for sending reports/alerts and enable only periodic license check on the backupdb to not get same reports/alert twice (from primary gui and from backup GUI)
How to set license checks to be made without processing alerts/reports (for backup db/GUI hosts) [[ Internal_support_hints#keep_the_license_updated_without_processing_alerts_reports ]]

Latest revision as of 02:37, 20 January 2023

Backup and restore GUI table settings script

the script is used for peridically restore of settings from primary db(GUI) host to a backup GUI(db) host. (can be used with migration instance to mirror also GUI settings not only calldata)


Requirements

the script requires to set at least variables: primaryhost,backupfilenameremote,backupfilenamelocal Folders in paths defined in sctipt needs to exists on the hosts, also it is necessary to allow passless access to primary host from secondary host as root and the script needs to be run under root user. The voipmontior GUI on backup host needs to points to backupdb

Script

#!/bin/bash
#from where to get GUI's data
primaryhost=1.2.3.4

#if backups should be kept locally
keepbackups=true

datestr=`date +'%Y%m%d-%H%M'`
backupfilenameremote="/root/voipmonitor/backupGUI_$datestr.zip"
backupfilenamelocal="/root/voipmonitor/backup/backupGUI_$datestr.zip"
remotecmdstr="cd /var/www/html; php php/run.php backupGuiTables -t config -f $backupfilenameremote"

#create backup on primary
ssh $primaryhost $remotecmdstr
#get the backup
scp -q $primaryhost:/$backupfilenameremote $backupfilenamelocal

#remove the backup file on the primary after copied
ssh $primaryhost rm $backupfilenameremote

#apply the backup here
cd /var/www/html
#echo php/run.php restoreGuiTables -t config -f $backupfilenamelocal
php php/run.php restoreGuiTables -t config -f $backupfilenamelocal

if [ "$keepbackups" = false ] ; then
  rm $backupfilenamelocal
fi

Crontab

Placed following line into /etc/crontab to backup and restore every 30 minutes

*/30 * * * * root /root/voipmonitor/backup_and_restore.sh

Then restart the crontab or send it HUP signall with kill command

Notes

Keep in mind that when GUI on primary is configured to send the emails, after the settings migrated to backup GUI/db it will try to send same emails as well - you should disable the deafult crontab line for sending reports/alerts and enable only periodic license check on the backupdb to not get same reports/alert twice (from primary gui and from backup GUI)

How to set license checks to be made without processing alerts/reports (for backup db/GUI hosts) Internal_support_hints#keep_the_license_updated_without_processing_alerts_reports