From 7966b0dff9985cca43912e53b0770f9a1c981b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20LU=C3=87I?= Date: Fri, 28 Nov 2014 21:50:48 +0100 Subject: Make restore one by one to help https://forum.pfsense.org/index.php?topic=84693.0 --- etc/inc/rrd.inc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'etc/inc') diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index e88105e..e058926 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -58,20 +58,24 @@ 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"); + return; } 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; -- cgit v1.1