} /** * OPTIONS * opts - if we have opts, run the backup from it, passing the file back when finisehed * id - if we have an id. If we do, just run a "regular" backup, using the id for options * and pulling all other data from the database * astdb - tools for handeling the astdb */ $getopt = (function_exists('_getopt') ? '_' : '') . 'getopt'; $vars = $getopt($short = '', $long = array('opts::', 'id::', 'astdb::', 'data::')); //if the id option was passed if (isset($vars['id']) && $vars['id']) { //bu = backup settings //s= servers //b= backup object if ($bu = backup_get_backup($vars['id'])) { //dont run if no storage servers were found if (!isset($bu['storage_servers']) || count($bu['storage_servers']) < 1) { backup_log(_('No storage servers found! Aborting.')); exit; } $s = backup_get_server('all_detailed'); $b = new FreePBX\modules\Backup\Backup($bu, $s); backup_log(_('Initializing Backup') . ' ' . $vars['id']); backup_clear_log(); $b->init(); if ($b->b['bu_server'] == "0") { // lock to prevent backups from being run concurrently while (!$b->acquire_lock()) { backup_log(_('waiting for lock...')); sleep(10);
function backup_set_backup_cron() { global $amp_conf; //remove all stale backup's edit_crontab($amp_conf['AMPBIN'] . '/backup.php'); $backups = backup_get_backup('all_detailed'); foreach ($backups as $b) { $cron = ''; // The ID porition of the command was added to better support other cron daemons (#7374) // We should be using the format of ID=[vendor]_[module raw name]_[id] $cron['command'] = 'ID=freepbx_backup_' . $b['id'] . ' ' . $amp_conf['AMPBIN'] . '/backup.php --id=' . $b['id']; if (!isset($b['cron_random']) || $b['cron_random'] != 'true') { switch ($b['cron_schedule']) { case 'never': $cron = ''; break; case 'hourly': case 'daily': case 'weekly': case 'monthly': case 'annually': case 'reboot': $cron['event'] = $b['cron_schedule']; break; case 'custom': $cron['minute'] = isset($b['cron_minute']) ? implode(',', $b['cron_minute']) : '*'; $cron['dom'] = isset($b['cron_dom']) ? implode(',', $b['cron_dom']) : '*'; $cron['dow'] = isset($b['cron_dow']) ? implode(',', $b['cron_dow']) : '*'; $cron['hour'] = isset($b['cron_hour']) ? implode(',', $b['cron_hour']) : '*'; $cron['month'] = isset($b['cron_month']) ? implode(',', $b['cron_month']) : '*'; break; } } else { switch ($b['cron_schedule']) { case 'annually': $cron['month'] = rand(1, 12); case 'monthly': $cron['dom'] = rand(1, 31); case 'weekly': if (!in_array($b['cron_schedule'], array('annually', 'monthly'))) { $cron['dow'] = rand(0, 6); } case 'daily': $hour = rand(0, 7) + 21; $cron['hour'] = $hour > 23 ? $hour - 23 : $hour; case 'hourly': $cron['minute'] = rand(0, 59); break; } } if ($cron) { //dbug('calling cron with ', $cron); edit_crontab('', $cron); } } }
public function getRightNav($request) { $var = array(); switch ($request['display']) { case 'backup': if (isset($request['action']) && $request['action'] == 'edit') { $var['backup'] = backup_get_backup('all'); } return load_view(dirname(__FILE__) . '/views/rnav/backup.php', $var); break; case 'backup_restore': $var['servers'] = backup_get_server('all'); return load_view(dirname(__FILE__) . '/views/rnav/restore.php', $var); break; case 'backup_servers': if (isset($request['action']) && $request['action'] == 'edit') { $var['servers'] = backup_get_server('all'); } return load_view(dirname(__FILE__) . '/views/rnav/servers.php', $var); break; case 'backup_templates': if (isset($request['action']) && $request['action'] == 'edit') { $var['templates'] = backup_get_template('all'); } return load_view(dirname(__FILE__) . '/views/rnav/templates.php', $var); break; } }
//send results back to the user backup_log($msg); } pclose($run); //send messgae to browser that were done backup_log('END'); exit; break; } //view action switch ($var['action']) { case 'edit': case 'save': $var['servers'] = backup_get_server('all'); $var['templates'] = backup_get_template('all_detailed'); $var = array_merge($var, backup_get_backup($var['id'])); $content = load_view(dirname(__FILE__) . '/views/backup/backup.php', $var); break; default: $content = load_view(dirname(__FILE__) . '/views/backup/backups.php', $var); break; } $heading = _("Backup and Restore"); ?> <div class="container-fluid"> <h1><?php echo $heading; ?> </h1> <div class = "display full-border">