How to backup settings of users and data of GUI by cron

From VoIPmonitor.org
Jump to navigation Jump to search

The goal is to have config of users and GUI backuped (not contain CDR data) each day.

following example script /root/backupguicfg.sh will create 3 files per day in /root/guiconfigs (dir needs to exists)

#!/bin/bash
day=`date "+%Y-%m-%d"`
filecfgt=/root/guiconfigs/cfgtables-${day}.txt
filedata=/root/guiconfigs/cfgdata-${day}.txt
filecfgf=/root/guiconfigs/cfgfiles-${day}.txt
php /var/www/html/php/run.php backupGuiTables -t config -f $filecfgt
php /var/www/html/php/run.php backupGuiTables -t data -f $filedata
php /var/www/html/php/run.php backupGuiConfigurationFiles -f $filecfgf


and into /etc/crontab set to start the script at 3:30 daily (nighttime when load is low)

30 3 * * * root /root/backupguicfg.sh

Then reload cron daemon settings to accept new line:

kill - HUP `pgrep cron`

Beware that script jsut do the backups - you need to clean old configs yourself or extend the script.