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
14fabe46
Commit
14fabe46
authored
Aug 01, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system: do not use self-made partial backups #1093 #471
parent
7d104204
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
74 deletions
+7
-74
xmlparse.inc
src/etc/inc/xmlparse.inc
+0
-18
diag_backup.php
src/www/diag_backup.php
+7
-56
No files found.
src/etc/inc/xmlparse.inc
View file @
14fabe46
...
...
@@ -132,11 +132,6 @@ function parse_xml_config($cffile, $rootobj, $isstring = "false")
{
global
$listtags
;
$listtags
=
listtags
();
if
(
isset
(
$GLOBALS
[
'custom_listtags'
]))
{
foreach
(
$GLOBALS
[
'custom_listtags'
]
as
$tag
)
{
$listtags
[
$tag
]
=
$tag
;
}
}
return
parse_xml_config_raw
(
$cffile
,
$rootobj
,
$isstring
);
}
...
...
@@ -268,18 +263,6 @@ function dump_xml_config_sub($arr, $indent)
return
$xmlconfig
;
}
function
dump_xml_config
(
$arr
,
$rootobj
)
{
global
$listtags
;
$listtags
=
listtags
();
if
(
isset
(
$GLOBALS
[
'custom_listtags'
]))
{
foreach
(
$GLOBALS
[
'custom_listtags'
]
as
$tag
)
{
$listtags
[
$tag
]
=
$tag
;
}
}
return
dump_xml_config_raw
(
$arr
,
$rootobj
);
}
function
dump_xml_config_raw
(
$arr
,
$rootobj
)
{
$xmlconfig
=
"<?xml version=
\"
1.0
\"
?"
.
">
\n
"
;
...
...
@@ -288,4 +271,3 @@ function dump_xml_config_raw($arr, $rootobj)
$xmlconfig
.=
"</
$rootobj
>
\n
"
;
return
$xmlconfig
;
}
?>
src/www/diag_backup.php
View file @
14fabe46
...
...
@@ -86,24 +86,6 @@ function restore_config_section($section_name, $new_contents)
return
true
;
}
/*
* backup_config_section($section): returns as an xml file string of
* the configuration section
*/
function
backup_config_section
(
$section_name
)
{
global
$config
;
$new_section
=
&
$config
[
$section_name
];
$xmlconfig
=
dump_xml_config
(
$new_section
,
$section_name
);
$xmlconfig
=
str_replace
(
"<?xml version=
\"
1.0
\"
?>"
,
""
,
$xmlconfig
);
/* KEEP THIS: unbreaks syntax highlighting <?php */
return
$xmlconfig
;
}
function
rrd_data_xml
()
{
$rrddbpath
=
'/var/db/rrd'
;
...
...
@@ -252,22 +234,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$name
=
"config-
{
$host
}
-"
.
date
(
"YmdHis"
)
.
".xml"
;
$data
=
""
;
if
(
empty
(
$_POST
[
'backuparea'
]))
{
/* backup entire configuration */
$data
=
file_get_contents
(
'/conf/config.xml'
);
}
elseif
(
$_POST
[
'backuparea'
]
===
"rrddata"
)
{
$data
=
rrd_data_xml
();
$name
=
"
{
$_POST
[
'backuparea'
]
}
-
{
$name
}
"
;
}
else
{
/* backup specific area of configuration */
$data
=
backup_config_section
(
$_POST
[
'backuparea'
]);
$name
=
"
{
$_POST
[
'backuparea'
]
}
-
{
$name
}
"
;
}
/* backup entire configuration */
$data
=
file_get_contents
(
'/conf/config.xml'
);
/*
* Backup RRD Data
*/
if
(
$_POST
[
'backuparea'
]
!==
"rrddata"
&&
empty
(
$_POST
[
'donotbackuprrd'
]))
{
/* backup RRD data */
if
(
empty
(
$_POST
[
'donotbackuprrd'
]))
{
$rrd_data_xml
=
rrd_data_xml
();
$closing_tag
=
"</opnsense>"
;
$data
=
str_replace
(
$closing_tag
,
$rrd_data_xml
.
$closing_tag
,
$data
);
...
...
@@ -340,7 +311,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
convert_config
();
}
filter_configure
();
$savemsg
=
gettext
(
"The configuration area has been restored.
You may need to
reboot the firewall."
);
$savemsg
=
gettext
(
"The configuration area has been restored.
You should
reboot the firewall."
);
}
}
else
{
/* restore the entire configuration */
...
...
@@ -539,15 +510,6 @@ $( document ).ready(function() {
$
(
"
#decrypt_opts
"
).
addClass
(
"
hidden
"
);
}
});
$
(
"
#backuparea
"
).
change
(
function
(
event
){
if
(
$
(
"
#backuparea
"
).
val
()
==
"
rrddata
"
)
{
$
(
"
#dotnotbackuprrd
"
).
prop
(
'
disabled
'
,
true
);
}
else
{
$
(
"
#dotnotbackuprrd
"
).
prop
(
'
disabled
'
,
false
);
}
});
});
//]]>
</script>
...
...
@@ -576,18 +538,6 @@ $( document ).ready(function() {
</tr>
<tr>
<td>
<?=
gettext
(
"Backup area:"
);
?>
<select
name=
"backuparea"
id=
"backuparea"
>
<option
value=
""
>
<?=
gettext
(
"ALL"
);
?>
</option>
<?php
foreach
(
$areas
as
$area
=>
$areaname
)
:
if
(
$area
!==
"rrddata"
&&
(
!
isset
(
$config
[
$area
])
||
!
is_array
(
$config
[
$area
])))
{
continue
;
};
?>
<option
value=
"
<?=
$area
;
?>
"
>
<?=
$areaname
;
?>
</option>
<?php
endforeach
;
?>
</select><br/>
<input
name=
"donotbackuprrd"
type=
"checkbox"
id=
"dotnotbackuprrd"
checked=
"checked"
/>
<?=
gettext
(
"Do not backup RRD data."
);
?>
<br/>
<input
name=
"encrypt"
type=
"checkbox"
id=
"encryptconf"
/>
...
...
@@ -746,6 +696,7 @@ $( document ).ready(function() {
<?php
include
(
"foot.inc"
);
?>
<?php
if
(
is_subsystem_dirty
(
'restore'
))
{
system_reboot
();
system_reboot
();
}
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