Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
5c8411fa
Commit
5c8411fa
authored
Mar 23, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add backup to cron
parent
5f2014cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
0 deletions
+26
-0
config.lib.inc
src/etc/inc/config.lib.inc
+6
-0
services.inc
src/etc/inc/services.inc
+13
-0
diag_backup.php
src/www/diag_backup.php
+7
-0
No files found.
src/etc/inc/config.lib.inc
View file @
5c8411fa
...
@@ -225,6 +225,12 @@ function write_config($desc = 'Unknown', $backup = true)
...
@@ -225,6 +225,12 @@ function write_config($desc = 'Unknown', $backup = true)
session_write_close
();
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
=
OPNsense\Core\Config
::
getInstance
();
$cnf
->
fromArray
(
$config
);
$cnf
->
fromArray
(
$config
);
$revision_info
=
make_config_revision_entry
(
$desc
);
$revision_info
=
make_config_revision_entry
(
$desc
);
...
...
src/etc/inc/services.inc
View file @
5c8411fa
...
@@ -2308,6 +2308,19 @@ function upnp_start() {
...
@@ -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"
)
{
function
install_cron_job
(
$command
,
$active
=
false
,
$minute
=
"0"
,
$hour
=
"*"
,
$monthday
=
"*"
,
$month
=
"*"
,
$weekday
=
"*"
,
$who
=
"root"
)
{
global
$config
,
$g
;
global
$config
,
$g
;
...
...
src/www/diag_backup.php
View file @
5c8411fa
...
@@ -41,6 +41,8 @@ require_once("guiconfig.inc");
...
@@ -41,6 +41,8 @@ require_once("guiconfig.inc");
require_once
(
"functions.inc"
);
require_once
(
"functions.inc"
);
require_once
(
"filter.inc"
);
require_once
(
"filter.inc"
);
require_once
(
"shaper.inc"
);
require_once
(
"shaper.inc"
);
require_once
(
"services.inc"
);
require_once
(
"util.inc"
);
$rrddbpath
=
'/var/db/rrd'
;
$rrddbpath
=
'/var/db/rrd'
;
$rrdtool
=
'/usr/local/bin/rrdtool'
;
$rrdtool
=
'/usr/local/bin/rrdtool'
;
...
@@ -508,6 +510,11 @@ if ($_POST) {
...
@@ -508,6 +510,11 @@ if ($_POST) {
// test / perform backup
// test / perform backup
try
{
try
{
$filesInBackup
=
backup_to_google_drive
()
;
$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
)
{
}
catch
(
Exception
$e
)
{
$filesInBackup
=
array
()
;
$filesInBackup
=
array
()
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment