Backup and restore GUI tables

From VoIPmonitor.org
Revision as of 17:43, 19 January 2023 by Petr.halounek (talk | contribs) (Created page with " #!/bin/bash #from where to get GUI's data primaryhost=10.112.5.77 #if backups should be kept locally keepbackups=true datestr=`date +'%Y%m%d-%H%M'` backupfilenamere...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#!/bin/bash
#from where to get GUI's data
primaryhost=10.112.5.77

#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