Added ADMIN_backup.pl script to create backups of all essential VICIDIAL and Asterisk files, including MySQL database.
git-svn-id: svn://192.168.202.10@796 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -50,13 +50,16 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom
|
||||
- AST_CRON_audio_2_compress.pl
|
||||
- AST_CRON_audio_3_ftp.pl
|
||||
|
||||
9. The 8 outbound agi-VDADtransfer scripts are in process of being consolidated
|
||||
9. Created a new script to backup a VICIDIAL setup, including the Asterisk conf
|
||||
files, prompt recordings, bin, agi and web files:
|
||||
ADMIN_backup.pl
|
||||
|
||||
10. The 8 outbound agi-VDADtransfer scripts are in process of being consolidated
|
||||
into a single AGI script: agi-VDAD_ALL_outbound.agi
|
||||
|
||||
10. The start of a new QC (Quality Control) feature [non functional right now]
|
||||
11. The start of a new QC (Quality Control) feature [non functional right now]
|
||||
|
||||
|
||||
11. Install the Switch perl module from CPAN
|
||||
12. Install the Switch perl module from CPAN
|
||||
perl -MCPAN -e shell
|
||||
- install Switch
|
||||
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# ADMIN_backup.pl version 2.0.5
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Backs-up the asterisk database, conf/agi/sounds/bin files
|
||||
#
|
||||
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGELOG
|
||||
#
|
||||
# 80316-2211 - First Build
|
||||
#
|
||||
|
||||
|
||||
$secT = time();
|
||||
$secX = time();
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
$year = ($year + 1900);
|
||||
$mon++;
|
||||
if ($mon < 10) {$mon = "0$mon";}
|
||||
if ($mday < 10) {$mday = "0$mday";}
|
||||
if ($hour < 10) {$Fhour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
$file_date = "$year-$mon-$mday";
|
||||
$now_date = "$year-$mon-$mday $hour:$min:$sec";
|
||||
$VDL_date = "$year-$mon-$mday 00:00:01";
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n";
|
||||
print " [--all] = *DEFAULT* show GMT offset of records as they are inserted into hopper\n";
|
||||
print " [--db-only] = only backup the database\n";
|
||||
print " [--conf-only] = only backup the asterisk conf files\n";
|
||||
print " [--without-db] = do not backup the database\n";
|
||||
print " [--without-conf] = do not backup the conf files\n";
|
||||
print " [--without-web] = do not backup web files\n";
|
||||
print " [--without-sounds] = do not backup asterisk sounds\n";
|
||||
print " [--ftp-transfer] = Transfer backup to FTP server\n";
|
||||
print " [--debugX] = super debug\n";
|
||||
print " [--debug] = debug\n";
|
||||
print " [-t] = test\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1; $FTPdebug=1;
|
||||
print "\n----- DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING -----\n\n";
|
||||
}
|
||||
if ($args =~ /--db-only/i)
|
||||
{
|
||||
$db_only=1;
|
||||
print "\n----- Backup Database Only -----\n\n";
|
||||
}
|
||||
if ($args =~ /--conf-only/i)
|
||||
{
|
||||
$conf_only=1;
|
||||
print "\n----- Conf Files Backup Only -----\n\n";
|
||||
}
|
||||
if ($args =~ /--without-db/i)
|
||||
{
|
||||
$without_db=1;
|
||||
print "\n----- No Database Backup -----\n\n";
|
||||
}
|
||||
if ($args =~ /--without-conf/i)
|
||||
{
|
||||
$without_conf=1;
|
||||
print "\n----- No Conf Files Backup -----\n\n";
|
||||
}
|
||||
if ($args =~ /--without-sounds/i)
|
||||
{
|
||||
$without_sounds=1;
|
||||
print "\n----- No Sounds Backup -----\n\n";
|
||||
}
|
||||
if ($args =~ /--without-web/i)
|
||||
{
|
||||
$without_web=1;
|
||||
print "\n----- No web files Backup -----\n\n";
|
||||
}
|
||||
if ($args =~ /--ftp-transfer/i)
|
||||
{
|
||||
$ftp_transfer=1;
|
||||
print "\n----- FTP transfer -----\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no command line options set\n";
|
||||
}
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
|
||||
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
||||
@conf = <conf>;
|
||||
close(conf);
|
||||
$i=0;
|
||||
foreach(@conf)
|
||||
{
|
||||
$line = $conf[$i];
|
||||
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
|
||||
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
|
||||
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
|
||||
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
|
||||
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
|
||||
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
|
||||
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
|
||||
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
|
||||
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
|
||||
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
|
||||
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
|
||||
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
|
||||
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) )
|
||||
{$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) )
|
||||
{$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) )
|
||||
{$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) )
|
||||
{$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) )
|
||||
{$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$ARCHIVEpath) {$ARCHIVEpath = "$PATHlogs/archive";}
|
||||
if (!$VARDB_port) {$VARDB_port='3306';}
|
||||
|
||||
### find tar binary to do the archiving
|
||||
$tarbin = '';
|
||||
if ( -e ('/usr/bin/tar')) {$tarbin = '/usr/bin/tar';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/tar')) {$tarbin = '/usr/local/bin/tar';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/bin/tar')) {$tarbin = '/bin/tar';}
|
||||
else
|
||||
{
|
||||
print "Can't find tar binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### find gzip binary to do the archiving
|
||||
$gzipbin = '';
|
||||
if ( -e ('/usr/bin/gzip')) {$gzipbin = '/usr/bin/gzip';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/gzip')) {$gzipbin = '/usr/local/bin/gzip';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/bin/gzip')) {$gzipbin = '/bin/gzip';}
|
||||
else
|
||||
{
|
||||
print "Can't find gzip binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### find mysqldump binary to do the database dump
|
||||
$mysqldumpbin = '';
|
||||
if ( -e ('/usr/bin/mysqldump')) {$mysqldumpbin = '/usr/bin/mysqldump';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/mysql/bin/mysqldump')) {$mysqldumpbin = '/usr/local/mysql/bin/mysqldump';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/bin/mysqldump')) {$mysqldumpbin = '/bin/mysqldump';}
|
||||
else
|
||||
{
|
||||
print "Can't find mysqldump binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$conf='_CONF_';
|
||||
$bin='_BIN_';
|
||||
$web='_WEB_';
|
||||
$sounds='_SOUNDS_';
|
||||
$all='_ALL_';
|
||||
$tar='.tar';
|
||||
$gz='.gz';
|
||||
|
||||
`cd $ARCHIVEpath`;
|
||||
`mkdir $ARCHIVEpath/temp`;
|
||||
|
||||
if ( ($without_db < 1) && ($conf_only < 1) )
|
||||
{
|
||||
### BACKUP THE MYSQL FILES ON THE DB SERVER ###
|
||||
`$mysqldumpbin --lock-tables --flush-logs $VARDB_database | $gzipbin > $ARCHIVEpath/temp/$VARserver_ip$VARDB_database$wday.gz`;
|
||||
}
|
||||
|
||||
if ( ($without_conf < 1) && ($db_only < 1) )
|
||||
{
|
||||
### BACKUP THE ASTERISK CONF FILES ON THE SERVER ###
|
||||
`$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$conf$wday$tar /etc/astguiclient.conf /etc/zaptel.conf /etc/asterisk`;
|
||||
}
|
||||
|
||||
if ( ($conf_only < 1) && ($db_only < 1) && ($without_web < 1) )
|
||||
{
|
||||
### BACKUP THE WEB FILES ON THE SERVER ###
|
||||
`$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$web$wday$tar $PATHweb`;
|
||||
}
|
||||
|
||||
if ( ($conf_only < 1) && ($db_only < 1) )
|
||||
{
|
||||
### BACKUP THE ASTGUICLIENT AND AGI FILES ON THE SERVER ###
|
||||
`$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$bin$wday$tar $PATHagi $PATHhome`;
|
||||
}
|
||||
|
||||
if ( ($conf_only < 1) && ($db_only < 1) && ($without_sounds < 1) )
|
||||
{
|
||||
### BACKUP THE ASTERISK SOUNDS ON THE SERVER ###
|
||||
`$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$sounds$wday$tar $PATHsounds`;
|
||||
}
|
||||
|
||||
### PUT EVERYTHING TOGETHER TO BE COMPRESSED ###
|
||||
`$tarbin cf $ARCHIVEpath/$VARserver_ip$all$wday$tar $ARCHIVEpath/temp`;
|
||||
|
||||
### COMPRESS THE ALL FILE ###
|
||||
`$gzipbin -9 $ARCHIVEpath/$VARserver_ip$all$wday$tar`;
|
||||
|
||||
### REMOVE TEMP FILES ###
|
||||
`rm -fR $ARCHIVEpath/temp`;
|
||||
|
||||
|
||||
#### FTP to the Backup server and upload the final file
|
||||
if ($ftp_transfer > 0)
|
||||
{
|
||||
use Net::FTP;
|
||||
$ftp = Net::FTP->new("$VARFTP_host", Port => "$VARFTP_port", Debug => "$FTPdebug");
|
||||
$ftp->login("$VARFTP_user","$VARFTP_pass");
|
||||
$ftp->cwd("$VARFTP_dir");
|
||||
$ftp->binary();
|
||||
$ftp->put("$ARCHIVEpath/$VARserver_ip$all$wday$tar$gz", "$VARserver_ip$all$wday$tar$gz");
|
||||
$ftp->quit;
|
||||
}
|
||||
|
||||
|
||||
exit;
|
||||
@@ -69,19 +69,6 @@ exten => i,1,Playback(invalid) ; "That's not valid, try again"
|
||||
exten => 8500,1,VoicemailMain
|
||||
exten => 8500,2,Goto(s,6)
|
||||
|
||||
; ASTERISK AGENTS LOGINS FOR QUEUES (NOT part of VICIDIAL)
|
||||
; the following assumes phone agent login and exten are 3 digits and the same
|
||||
; also assumes that 3-digit login is present in agents.conf and queueus.conf
|
||||
;Agent Logout then stay onhook, DIAL 54 + 3-digit ID
|
||||
exten => _54XXX,1,AgentCallbackLogin(||)
|
||||
; the following are used to login and logout of Asterisk Queues from phone
|
||||
;Agent Login then stay offhook on the phone, DIAL 55 + 3-digit ID
|
||||
exten => _55XXX,1,AgentLogin(${EXTEN:1})
|
||||
;Agent Login then stay onhook, phones will ring, DIAL 56 + 3-digit ID
|
||||
exten => _56XXX,1,AgentCallbackLogin(||${EXTEN:1}@default)
|
||||
|
||||
|
||||
|
||||
; FastAGI for VICIDIAL/astGUIclient call logging
|
||||
exten => h,1,DeadAGI(agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME})
|
||||
|
||||
@@ -124,16 +111,16 @@ exten => _91866NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
||||
exten => _91866NXXXXXX,2,Dial(${TRUNK}/${EXTEN:1},,To)
|
||||
exten => _91866NXXXXXX,3,Hangup
|
||||
|
||||
; dial a local outbound number (modified because of only LD T1)
|
||||
exten => _9NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
||||
exten => _9NXXXXXX,2,Dial(${TRUNK}/1727${EXTEN:1},,To)
|
||||
exten => _9NXXXXXX,3,Hangup
|
||||
|
||||
; dial a local 727 outbound number with area code
|
||||
exten => _9727NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
||||
exten => _9727NXXXXXX,2,Dial(${TRUNK}/1${EXTEN:1},,To)
|
||||
exten => _9727NXXXXXX,3,Hangup
|
||||
|
||||
; dial a local 813 outbound number with area code
|
||||
exten => _9813NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
||||
exten => _9813NXXXXXX,2,Dial(${TRUNK}/${EXTEN:1},,To)
|
||||
exten => _9813NXXXXXX,3,Hangup
|
||||
|
||||
; dial a long distance outbound number
|
||||
; This 'o' Dial flag is VERY important for VICIDIAL on outbound calls
|
||||
exten => _91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
||||
@@ -148,11 +135,6 @@ exten => _91NXXNXXXXXX,3,Hangup
|
||||
; exten => _91NXXNXXXXXX,2,Dial(sip/${EXTEN}@SIPtrunk,55,o)
|
||||
; exten => _91NXXNXXXXXX,3,Hangup
|
||||
|
||||
; dial a local outbound number (modified because of only LD T1)
|
||||
exten => _9NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
||||
exten => _9NXXXXXX,2,Dial(${TRUNK}/1727${EXTEN:1},,To)
|
||||
exten => _9NXXXXXX,3,Hangup
|
||||
|
||||
; parameters for call_inbound.agi (7 fields separated by five dashes "-----"):
|
||||
; 1. the extension of the phone to ring as defined in the asterisk.phones table
|
||||
; 2. the phone number that was called, for the live_inbound/_log entry
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# 80115-1426 - Added ip_relay scripts for port forwarding
|
||||
# 80122-0320 - Added build_phones_conf flag to generate phones conf entries from phones table records
|
||||
# 80227-1536 - Added ip_relay to keepalive list
|
||||
# 80316-2208 - Added $PATHlogs/archive for backups
|
||||
#
|
||||
|
||||
############################################
|
||||
@@ -2116,6 +2117,9 @@ if ($WEBONLY < 1)
|
||||
`chmod -R 0766 $PATHmonitor`;
|
||||
`chmod -R 0766 $PATHDONEmonitor`;
|
||||
|
||||
print "Creating $PATHlogs/archive directory for backups...\n";
|
||||
`mkdir -p $PATHlogs/archive`;
|
||||
|
||||
print "Copying bin scripts to $PATHhome ...\n";
|
||||
`cp -f ./bin/* $PATHhome/`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user