"; echo _("DELETE ALL THE DATA IN THIS SET"); echo ""; echo _("Delete this backup set and all data associated with this backup set..");echo "
"; echo "
"; } if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false) { if (($file!=".") && ($file!="..") && ($dir==$amp_conf['ASTVARLIBDIR']."/backups/")) echo "
  • $file
  • "; else if (($file!=".") && ($file!="..") ) echo "
  • $file
  • "; } closedir($dh); } } else if (substr($dir, -6)=="tar.gz" ){ echo "
  • "; echo _("Delete File Set"); echo ""; echo _("Delete this backup set."); echo "
  • "; echo "
    "; $tar_string="tar tfz \"$dir\" | cut -d'/' -f4"; exec($tar_string,$restore_files,$error); echo "
  • "; echo _("Restore Entire Backup Set"); echo ""; echo _("Restore your Complete Backup set overwriting all files."); echo "
  • "; echo "
    "; if (array_search('voicemail.tar.gz',$restore_files)){ echo "
  • "; echo _("Restore VoiceMail Files");echo ""; echo _("Restore your Voicemail files from this backup set. NOTE! This will delete any voicemail currently in the voicemail boxes."); echo "
  • "; echo "
    "; } if (array_search('recordings.tar.gz',$restore_files)){ echo "
  • "; echo _("Restore System Recordings Files"); echo ""; echo _("Restore your system Voice Recordings including AutoAttendent files from this backup set. NOTE! This will OVERWRITE any voicerecordings currently on the system. It will NOT delete new files not currently in the backup set"); echo "
  • "; echo "
    "; } if (array_search('configurations.tar.gz',$restore_files)){ echo "
  • "; echo _("Restore System Configuration"); echo ""; echo _("Restore your system configuration from this backup set. NOTE! This will OVERWRITE any System changes you have made since this backup... ALL Itemes will be reset to what they were at the time of this backup set.."); echo "
  • "; echo "
    "; } if (array_search('fop.tar.gz',$restore_files)){ echo "
  • "; echo _("Restore Operator Panel"); echo ""; echo _("Restore the Operator Panel from this backup set. NOTE! This will OVERWRITE any Operator Panel Changes you have made since this backup... ALL Itemes will be reset to what they were at the time of this backup set.."); echo "
  • "; echo "
    "; } if (array_search('cdr.tar.gz',$restore_files)){ echo "
  • "; echo _("Restore Call Detail Report"); echo ""; echo _("Restore the Call Detail Records from this backup set. NOTE! This will DELETE ALL CALL RECORDS that have been saved since this backup set.."); echo "
  • "; echo "
    "; } } else{ echo "

    "; echo _("ERROR its not a BACKUP SET file");echo "

    "; } } function Restore_Tar_Files($dir="", $file="",$filetype="", $display="") { global $asterisk_conf; global $amp_conf; $Message="Restore Failed"; if($filetype=="ALL") { $Message="Restored All Files in BackupSet"; $fileholder=substr($file, 0,-7); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); // First restore voicemial (for some reason if you do it all at once these don't get restored // exec('/bin/rm -rf '.$amp_conf['ASTSPOOLDIR'].'/voicemail'); $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | tar -Pxvz"; exec($tar_cmd); // Next, recordings cause same issue as above // $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | tar -Pxvz"; exec($tar_cmd); // Now the rest and then we'll get on with the databases // $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | tar -Pxvz"; exec($tar_cmd); $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz /tmp/ampbackups.$fileholder/cdr.tar.gz | tar -Pxvz"; exec($tar_cmd); $tar_cmd="tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/asteriskcdr.sql /tmp/ampbackups.$fileholder/astdb.dump"; exec($tar_cmd); $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asterisk.sql"; exec($sql_cmd); $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asteriskcdr.sql"; exec($sql_cmd); exec($amp_conf['AMPBIN']."/restoreastdb.php $fileholder"); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); /* $fh = fopen("/tmp/backup.log","w"); fwrite($fh,"RET is: $RETCODE Just deleted file\n"); fwrite($fh,"OUTPUT: %s\n",print_r($OUTPUT,true)); fclose($fh); */ } else if($filetype=="VoiceMail") { $Message="Restored VoiceMail"; $fileholder=substr($file, 0,-7); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); exec('/bin/rm -rf '.$amp_conf['ASTSPOOLDIR'].'/voicemail'); $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | tar -Pxvz"; exec($tar_cmd); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); } else if($filetype=="Recordings") { $Message="Restored System Recordings"; $fileholder=substr($file, 0,-7); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | tar -Pxvz"; exec($tar_cmd); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); } else if($filetype=="Configurations"){ $Message="Restored System Configuration"; $fileholder=substr($file, 0,-7); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | tar -Pxvz"; exec($tar_cmd); $tar_cmd="tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/astdb.dump"; exec($tar_cmd); $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asterisk.sql"; exec($sql_cmd); exec($amp_conf['AMPBIN']."/restoreastdb.php $fileholder"); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); } else if($filetype=="FOP"){ $Message="Restored Operator Panel"; $fileholder=substr($file, 0,-7); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz | tar -Pxvz"; exec($tar_cmd); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); } else if($filetype=="CDR"){ $Message="Restored CDR logs"; $fileholder=substr($file, 0,-7); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/cdr.tar.gz | tar -Pxvz"; exec($tar_cmd); $tar_cmd="tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asteriskcdr.sql"; exec($tar_cmd); $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asteriskcdr.sql"; exec($sql_cmd); exec("/bin/rm -rf /tmp/ampbackups.$fileholder"); } return ($Message); } function Get_Backup_Sets() { global $db; $sql = "SELECT * FROM Backup"; $results = $db->getAll($sql); if(DB::IsError($results)) { $results = null; } return $results; } function Delete_Backup_Set($ID="") { global $db; global $asterisk_conf; $sql = "DELETE FROM Backup WHERE ID = '$ID'"; $result = $db->query($sql); if(DB::IsError($result)) { die_freepbx($result->getMessage()); } $Cron_Script=$asterisk_conf['astvarlibdir']."/bin/retrieve_backup_cron_from_mysql.pl"; exec($Cron_Script); } function Save_Backup_Schedule($Backup_Parms, $backup_options ) { global $db; global $asterisk_conf; if ($Backup_Parms[1]=="now") { $Cron_Script=$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl '$Backup_Parms[0]' $backup_options[0] $backup_options[1] $backup_options[2] $backup_options[3] $backup_options[4]"; //echo "$Cron_Script"; exec($Cron_Script); } $sql = "INSERT INTO Backup (Name, Voicemail, Recordings, Configurations, CDR, FOP, Minutes, Hours, Days, Months,Weekdays, Command, Method ) VALUES ("; $sql .= "'".$Backup_Parms[0]."',"; $sql .= "'".$backup_options[0]."',"; $sql .= "'".$backup_options[1]."',"; $sql .= "'".$backup_options[2]."',"; $sql .= "'".$backup_options[3]."',"; $sql .= "'".$backup_options[4]."',"; $sql .= "'".$Backup_Parms[2]."',"; $sql .= "'".$Backup_Parms[3]."',"; $sql .= "'".$Backup_Parms[4]."',"; $sql .= "'".$Backup_Parms[5]."',"; $sql .= "'".$Backup_Parms[6]."',"; $sql .= "'".$Backup_Parms[7]."',"; $sql .= "'".$Backup_Parms[1]."');"; $result = $db->query($sql); if(DB::IsError($result)) { die_freepbx($result->getMessage().'
    '.$sql); } $Cron_Script=$asterisk_conf['astvarlibdir']."/bin/retrieve_backup_cron_from_mysql.pl"; exec($Cron_Script); } function Get_Backup_String($name, $backup_schedule, $ALL_days, $ALL_months, $ALL_weekdays, $mins="", $hours="", $days="", $months="", $weekdays="") { global $asterisk_conf; if ($backup_schedule=="hourly") $Cron_String="0 * * * * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl"; else if ($backup_schedule=="daily") $Cron_String="0 0 * * * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl"; else if ($backup_schedule=="weekly") $Cron_String="0 0 * * 0 ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl"; else if ($backup_schedule=="monthly") $Cron_String="0 0 1 * * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl"; else if ($backup_schedule=="yearly") $Cron_String="0 0 1 1 * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl"; else if ($backup_schedule=="follow_schedule") { if (count($mins)<1) $mins_string=":0:"; else{ foreach ($mins as $value) $mins_string.=":$value:"; } if (count($hours)<1) $hours_string=":0:"; else{ foreach ($hours as $value) $hours_string.=":$value:"; } if(($ALL_days=="1")||(count($days)<1)) $days_string="*"; else{ foreach ($days as $value) $days_string.=":$value:"; } if(($ALL_months=="1")||(count($months)<1)) $months_string="*"; else{ foreach ($months as $value) $months_string.=":$value:"; } if($ALL_weekdays=="1"||(count($weekdays)<1)) $weekdays_string="*"; else{ foreach ($weekdays as $value) $weekdays_string.=":$value:"; } $cron_mins_string=trim($mins_string,":"); $cron_hours_string=trim($hours_string,":"); $cron_days_string=trim($days_string,":"); $cron_months_string=trim($months_string,":"); $cron_weekdays_string=trim($weekdays_string,":"); $Cron_String=str_replace("::", ",", "$cron_mins_string $cron_hours_string $cron_days_string $cron_months_string $cron_weekdays_string ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl"); } else if ($backup_schedule=="now") $Cron_String="0 0 0 0 0 ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl"; $Backup_String[]="$name"; $Backup_String[]="$backup_schedule"; $Backup_String[]="$mins_string"; $Backup_String[]="$hours_string"; $Backup_String[]="$days_string"; $Backup_String[]="$months_string"; $Backup_String[]="$weekdays_string"; $Backup_String[]="$Cron_String"; return ($Backup_String); } function Get_Backup_Times($BackupID) { global $db; $sql = "SELECT Minutes, Hours, Days, Months, Weekdays, Method From Backup where ID=\"$BackupID\""; $results = $db->getAll($sql); if(DB::IsError($results)) { $results = Array(null, null, null, null, null, null); } return $results; } function Get_Backup_Options($BackupID) { global $db; $sql = "SELECT Name, Voicemail, Recordings, Configurations, CDR, FOP FROM Backup where ID=\"$BackupID\""; $results = $db->getAll($sql); if(DB::IsError($results)) { $results = Array(null, null, null, null, null, null); } return $results; } function Show_Backup_Options($ID="") { if ($ID==""){ $name=""; $voicemail="no"; $sysrecordings="no"; $sysconfig="no"; $cdr="no"; $fop="no";} else{ $backup_options=Get_Backup_Options($ID); foreach ($backup_options as $bk_options) $name="$bk_options[0]";$voicemail="$bk_options[1]"; $sysrecordings="$bk_options[2]"; $sysconfig="$bk_options[3]"; $cdr="$bk_options[4]"; $fop="$bk_options[5]"; } ?> :           :           :           :           :          
    "; echo ""; echo ""; echo "
    "; } function Schedule_Show_Hours($Hours_Set="") { echo "

    "; echo ""; echo ""; echo "
    "; } function Schedule_Show_Days($Days_Set="") { if (($Days_Set=="") || ($Days_Set=="*")){ echo ""; echo _("All"); echo "
    "; echo ""; echo _("Selected"); echo "
    "; } else{ echo ""; echo _("All"); echo "
    "; echo ""; echo _("Selected"); echo "
    "; } echo ""; echo ""; echo ""; echo "
    "; } function Schedule_Show_Months($Months_Set="") { if (($Months_Set=="") || ($Months_Set=="*")){ echo ""; echo _("All"); echo "
    "; echo ""; echo _("Selected"); echo "
    "; } else{ echo ""; echo _("All"); echo "
    "; echo ""; echo _("Selected"); echo "
    "; } echo ""; echo ""; echo "
    "; } function Schedule_Show_Weekdays($Weekdays_Set="") { if (($Weekdays_Set=="") || ($Weekdays_Set=="*")){ echo "";echo _("All"); echo "
    "; echo "";echo _("Selected"); echo "
    "; } else{ echo "";echo _("All"); echo "
    "; echo "";echo _("Selected"); echo "
    "; } echo ""; echo ""; echo "
    "; } function show_quickbar($Method="") { ?> "; echo ""._("Minutes")." "._("Hours")." "._("Days")." "._("Months").""._("Weekdays")." "; echo ""; Schedule_Show_Minutes($Minutes); echo ""; Schedule_Show_Hours($Hours); echo ""; Schedule_Show_Days($Days); echo ""; Schedule_Show_Months($Months); echo ""; Schedule_Show_Weekdays($Weekdays); }