summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorColin Smith <colin@pfsense.org>2005-05-17 21:43:25 +0000
committerColin Smith <colin@pfsense.org>2005-05-17 21:43:25 +0000
commitdc74c78af76caef223183f250ad80354a108b07f (patch)
tree32a6bdf05833c02c7021dedfec9ce76532c0637b /etc/inc
parent392a9bb8bb546437ba37900b7e1f3d1b0addada7 (diff)
downloadpfsense-dc74c78af76caef223183f250ad80354a108b07f.zip
pfsense-dc74c78af76caef223183f250ad80354a108b07f.tar.gz
Make sure we have a backup.cache before cleaning.
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/config.inc75
1 files changed, 38 insertions, 37 deletions
diff --git a/etc/inc/config.inc b/etc/inc/config.inc
index 48e780a..5df1bcf 100644
--- a/etc/inc/config.inc
+++ b/etc/inc/config.inc
@@ -963,47 +963,48 @@ function cleanup_backupcache($bootup = false, $revisions = "all") {
if($bootup) print " done.\n";
return;
}
- global $g;
- $backups = get_backups();
- $newbaks = array();
- $bakfiles = glob("/conf/backup/*");
- $baktimes = $backups['versions'];
- $tocache = array();
- unset($backups['versions']);
- foreach($bakfiles as $backup) { // Check for backups in the directory not represented in the cache.
- if(stristr($backup, 'backup.cache')) continue;
- $tocheck = array_shift(explode('.', array_pop(explode('-', $backup))));
- if(!in_array($tocheck, $baktimes)) {
- $i = true;
- if($bootup) print " " . $tocheck . "a";
- $newxml = parse_xml_config($backup, $g['xml_rootobj']);
- if($newxml['revision']['description'] == "") $newxml['revision']['description'] = "Unknown";
- $tocache[$tocheck] = array('description' => $newxml['revision']['description']);
- }
- }
- foreach($backups as $checkbak) {
- if(count(preg_grep('/' . $checkbak['time'] . '/i', $bakfiles)) != 0) {
- $newbaks[] = $checkbak;
- } else {
- $i = true;
- if($bootup) print " " . $tocheck . "r";
+ if(file_exists($g['cf_conf_path'] . '/backup/backup.cache')) {
+ $backups = get_backups();
+ $newbaks = array();
+ $bakfiles = glob("/conf/backup/*");
+ $baktimes = $backups['versions'];
+ $tocache = array();
+ unset($backups['versions']);
+ foreach($bakfiles as $backup) { // Check for backups in the directory not represented in the cache.
+ if(stristr($backup, 'backup.cache')) continue;
+ $tocheck = array_shift(explode('.', array_pop(explode('-', $backup))));
+ if(!in_array($tocheck, $baktimes)) {
+ $i = true;
+ if($bootup) print " " . $tocheck . "a";
+ $newxml = parse_xml_config($backup, $g['xml_rootobj']);
+ if($newxml['revision']['description'] == "") $newxml['revision']['description'] = "Unknown";
+ $tocache[$tocheck] = array('description' => $newxml['revision']['description']);
+ }
+ }
+ foreach($backups as $checkbak) {
+ if(count(preg_grep('/' . $checkbak['time'] . '/i', $bakfiles)) != 0) {
+ $newbaks[] = $checkbak;
+ } else {
+ $i = true;
+ if($bootup) print " " . $tocheck . "r";
+ }
}
- }
- foreach($newbaks as $todo) $tocache[$todo['time']] = array('description' => $todo['description']);
- if(is_integer($revisions)) {
- $toslice = array_slice(array_keys($tocache), 0, $revisions);
- foreach($toslice as $sliced) $newcache[$sliced] = $tocache[$sliced];
- foreach($tocache as $version => $versioninfo) {
- if(!in_array($version, array_keys($newcache))) {
- unlink_if_exists($g['conf_path'] . '/backup/config-' . $version . '.xml');
- if($bootup) print " " . $tocheck . "d";
+ foreach($newbaks as $todo) $tocache[$todo['time']] = array('description' => $todo['description']);
+ if(is_integer($revisions)) {
+ $toslice = array_slice(array_keys($tocache), 0, $revisions);
+ foreach($toslice as $sliced) $newcache[$sliced] = $tocache[$sliced];
+ foreach($tocache as $version => $versioninfo) {
+ if(!in_array($version, array_keys($newcache))) {
+ unlink_if_exists($g['conf_path'] . '/backup/config-' . $version . '.xml');
+ if($bootup) print " " . $tocheck . "d";
+ }
}
+ $tocache = $newcache;
}
- $tocache = $newcache;
+ $bakout = fopen($g['cf_conf_path'] . '/backup/backup.cache', "w");
+ fwrite($bakout, serialize($tocache));
+ fclose($bakout);
}
- $bakout = fopen($g['cf_conf_path'] . '/backup/backup.cache', "w");
- fwrite($bakout, serialize($tocache));
- fclose($bakout);
if($bootup) {
if($i) {
print ".\n";
OpenPOWER on IntegriCloud