Commit 14fabe46 authored by Franco Fichtner's avatar Franco Fichtner

system: do not use self-made partial backups #1093 #471

parent 7d104204
...@@ -132,11 +132,6 @@ function parse_xml_config($cffile, $rootobj, $isstring = "false") ...@@ -132,11 +132,6 @@ function parse_xml_config($cffile, $rootobj, $isstring = "false")
{ {
global $listtags; global $listtags;
$listtags = 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); return parse_xml_config_raw($cffile, $rootobj, $isstring);
} }
...@@ -268,18 +263,6 @@ function dump_xml_config_sub($arr, $indent) ...@@ -268,18 +263,6 @@ function dump_xml_config_sub($arr, $indent)
return $xmlconfig; 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) function dump_xml_config_raw($arr, $rootobj)
{ {
$xmlconfig = "<?xml version=\"1.0\"?" . ">\n"; $xmlconfig = "<?xml version=\"1.0\"?" . ">\n";
...@@ -288,4 +271,3 @@ function dump_xml_config_raw($arr, $rootobj) ...@@ -288,4 +271,3 @@ function dump_xml_config_raw($arr, $rootobj)
$xmlconfig .= "</$rootobj>\n"; $xmlconfig .= "</$rootobj>\n";
return $xmlconfig; return $xmlconfig;
} }
?>
...@@ -86,24 +86,6 @@ function restore_config_section($section_name, $new_contents) ...@@ -86,24 +86,6 @@ function restore_config_section($section_name, $new_contents)
return true; 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() function rrd_data_xml()
{ {
$rrddbpath = '/var/db/rrd'; $rrddbpath = '/var/db/rrd';
...@@ -252,22 +234,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -252,22 +234,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$name = "config-{$host}-".date("YmdHis").".xml"; $name = "config-{$host}-".date("YmdHis").".xml";
$data = ""; $data = "";
if(empty($_POST['backuparea'])) {
/* backup entire configuration */ /* backup entire configuration */
$data = file_get_contents('/conf/config.xml'); $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 RRD data */
* Backup RRD Data if (empty($_POST['donotbackuprrd'])) {
*/
if ($_POST['backuparea'] !== "rrddata" && empty($_POST['donotbackuprrd'])) {
$rrd_data_xml = rrd_data_xml(); $rrd_data_xml = rrd_data_xml();
$closing_tag = "</opnsense>"; $closing_tag = "</opnsense>";
$data = str_replace($closing_tag, $rrd_data_xml . $closing_tag, $data); $data = str_replace($closing_tag, $rrd_data_xml . $closing_tag, $data);
...@@ -340,7 +311,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -340,7 +311,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
convert_config(); convert_config();
} }
filter_configure(); 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 { } else {
/* restore the entire configuration */ /* restore the entire configuration */
...@@ -539,15 +510,6 @@ $( document ).ready(function() { ...@@ -539,15 +510,6 @@ $( document ).ready(function() {
$("#decrypt_opts").addClass("hidden"); $("#decrypt_opts").addClass("hidden");
} }
}); });
$("#backuparea").change(function(event){
if ($("#backuparea").val() == "rrddata") {
$("#dotnotbackuprrd").prop('disabled', true);
} else {
$("#dotnotbackuprrd").prop('disabled', false);
}
});
}); });
//]]> //]]>
</script> </script>
...@@ -576,18 +538,6 @@ $( document ).ready(function() { ...@@ -576,18 +538,6 @@ $( document ).ready(function() {
</tr> </tr>
<tr> <tr>
<td> <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" /> <input name="donotbackuprrd" type="checkbox" id="dotnotbackuprrd" checked="checked" />
<?=gettext("Do not backup RRD data."); ?><br/> <?=gettext("Do not backup RRD data."); ?><br/>
<input name="encrypt" type="checkbox" id="encryptconf" /> <input name="encrypt" type="checkbox" id="encryptconf" />
...@@ -746,6 +696,7 @@ $( document ).ready(function() { ...@@ -746,6 +696,7 @@ $( document ).ready(function() {
<?php include("foot.inc"); ?> <?php include("foot.inc"); ?>
<?php <?php
if (is_subsystem_dirty('restore')) { if (is_subsystem_dirty('restore')) {
system_reboot(); system_reboot();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment