diff options
author | Ermal LUÇI <eri@pfsense.org> | 2014-12-01 09:47:00 +0100 |
---|---|---|
committer | Ermal LUÇI <eri@pfsense.org> | 2014-12-01 09:47:00 +0100 |
commit | be544b90257dae5aacbed80955cf9f91cc845551 (patch) | |
tree | 0ed31e38d4db0143dc3bea7a1404c0d1ea5af432 /etc/inc/rrd.inc | |
parent | 02b81e84d4395a331ea9bf8cff06d02236fb469d (diff) | |
download | pfsense-be544b90257dae5aacbed80955cf9f91cc845551.zip pfsense-be544b90257dae5aacbed80955cf9f91cc845551.tar.gz |
Ticket #4053, manually merge improvements on rrd restore handling.
Diffstat (limited to 'etc/inc/rrd.inc')
-rw-r--r-- | etc/inc/rrd.inc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index 16d7aaa..1ae33c2 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -58,27 +58,30 @@ function restore_rrd() { foreach (glob("{$rrddbpath}/*.xml") as $xml_file) { @unlink($xml_file); } - $_gb = exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/rrd.tgz 2>&1", $rrdrestore, $rrdreturn); - $rrdrestore = implode(" ", $rrdrestore); + unset($rrdrestore); + $_gb = exec("cd /;LANG=C /usr/bin/tar -tf {$g['cf_conf_path']}/rrd.tgz", $rrdrestore, $rrdreturn); if($rrdreturn != 0) { log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n"); } - unset($rrdrestore); - foreach (glob("{$rrddbpath}/*.xml") as $xml_file) { - $rrd_file = preg_replace('/\.xml$/', ".rrd", $xml_file); - if (file_exists("{$rrd_file}")) { + foreach ($rrdrestore as $xml_file) { + $rrd_file = '/' . substr($xml_file, 0, -4) . '.rrd'; + if (file_exists("{$rrd_file}")) @unlink($rrd_file); + file_put_contents("{$g['tmp_path']}/rrd_restore", $xml_file); + $_gb = exec("cd /;LANG=C /usr/bin/tar -xf {$g['cf_conf_path']}/rrd.tgz -T {$g['tmp_path']}/rrd_restore"); + if (!file_exists("/{$xml_file}")) { + log_error("Could not extract {$xml_file} RRD xml file from archive!"); + continue; } - $output = array(); - $status = null; - $_gb = exec("$rrdtool restore -f '{$xml_file}' '{$rrd_file}'", $output, $status); + $_gb = exec("$rrdtool restore -f '/{$xml_file}' '{$rrd_file}'", $output, $status); if ($status) { log_error("rrdtool restore -f '{$xml_file}' '{$rrd_file}' failed returning {$status}."); continue; } unset($output); - @unlink($xml_file); + @unlink("/{$xml_file}"); } + unset($rrdrestore); /* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */ if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) { unlink_if_exists("{$g['cf_conf_path']}/rrd.tgz"); |