mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-18 02:25:05 +00:00
add backup to cron
This commit is contained in:
parent
5f2014cc7e
commit
5c8411faf4
@ -225,6 +225,12 @@ function write_config($desc = 'Unknown', $backup = true)
|
||||
session_write_close();
|
||||
}
|
||||
|
||||
if (!isset($config['version'])) {
|
||||
// Examine config.xml, if for some strange reason the content is unexpected : exit directly.
|
||||
log_error(gettext("WARNING: Corrupt config!"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
$cnf = OPNsense\Core\Config::getInstance();
|
||||
$cnf->fromArray($config);
|
||||
$revision_info = make_config_revision_entry($desc);
|
||||
|
||||
@ -2308,6 +2308,19 @@ function upnp_start() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check if cron exists
|
||||
*/
|
||||
function cron_job_exists($command) {
|
||||
global $config;
|
||||
foreach($config['cron']['item'] as $item) {
|
||||
if(strstr($item['command'], $command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function install_cron_job($command, $active=false, $minute="0", $hour="*", $monthday="*", $month="*", $weekday="*", $who="root") {
|
||||
global $config, $g;
|
||||
|
||||
|
||||
@ -41,6 +41,8 @@ require_once("guiconfig.inc");
|
||||
require_once("functions.inc");
|
||||
require_once("filter.inc");
|
||||
require_once("shaper.inc");
|
||||
require_once("services.inc");
|
||||
require_once("util.inc");
|
||||
|
||||
$rrddbpath = '/var/db/rrd';
|
||||
$rrdtool = '/usr/local/bin/rrdtool';
|
||||
@ -508,6 +510,11 @@ if ($_POST) {
|
||||
// test / perform backup
|
||||
try {
|
||||
$filesInBackup = backup_to_google_drive() ;
|
||||
$cron_job = "/usr/local/opnsense/scripts/remote_backup.php";
|
||||
if (!cron_job_exists($cron_job)) {
|
||||
// initial cron job install
|
||||
install_cron_job($cron_job,true,0,1);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$filesInBackup = array() ;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user