summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2010-08-09 16:12:52 -0400
committerjim-p <jimp@pfsense.org>2010-08-09 16:14:29 -0400
commit85405c11a0ab41d26e5016b055b2f1188317c8f2 (patch)
tree068661bb6c8342a91ea4730fc04a9c532eb9e3db
parent0c77c314c441b9f1a9967a9bdc0ee6ad0a8fc90b (diff)
downloadpfsense-85405c11a0ab41d26e5016b055b2f1188317c8f2.zip
pfsense-85405c11a0ab41d26e5016b055b2f1188317c8f2.tar.gz
Add the ability to set a periodic RRD and DHCP leases backup from Diagnostics > NanoBSD.
-rw-r--r--etc/inc/services.inc42
-rwxr-xr-xusr/local/www/diag_nanobsd.php53
2 files changed, 95 insertions, 0 deletions
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index 0c4c8de..de186d0 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -1305,4 +1305,46 @@ function upnp_start() {
}
}
+function install_cron_job($command, $active=false, $minute="0", $hour="*", $monthday="*", $month="*", $weekday="*", $who="root") {
+ global $config, $g;
+
+ $is_installed = false;
+
+ if(!$config['cron']['item'])
+ return;
+
+ $x=0;
+ foreach($config['cron']['item'] as $item) {
+ if(strstr($item['command'], $command)) {
+ $is_installed = true;
+ break;
+ }
+ $x++;
+ }
+
+ if($active) {
+ $cron_item = array();
+ $cron_item['minute'] = $minute;
+ $cron_item['hour'] = $hour;
+ $cron_item['mday'] = $monthday;
+ $cron_item['month'] = $month;
+ $cron_item['wday'] = $weekday;
+ $cron_item['who'] = $who;
+ $cron_item['command'] = $command;
+ if(!$is_installed) {
+ $config['cron']['item'][] = $cron_item;
+ write_config("Installed cron job for {$command}");
+ } else {
+ $config['cron']['item'][$x] = $cron_item;
+ write_config("Updated cron job for {$command}");
+ }
+ } else {
+ if(($is_installed == true) && ($x > 0)) {
+ unset($config['cron']['item'][$x]);
+ write_config("Remvoed cron job for {$command}");
+ }
+ }
+ configure_cron();
+}
+
?>
diff --git a/usr/local/www/diag_nanobsd.php b/usr/local/www/diag_nanobsd.php
index db96484..2ddcf9e 100755
--- a/usr/local/www/diag_nanobsd.php
+++ b/usr/local/www/diag_nanobsd.php
@@ -100,6 +100,16 @@ EOF;
nanobsd_detect_slice_info();
}
+if (isset($_POST['rrdbackup'])) {
+ $config['system']['rrdbackup'] = $_POST['rrdbackup'];
+ install_cron_job("/etc/rc.backup_rrd.sh", ($config['system']['rrdbackup'] > 0), $minute="0", "*/{$config['system']['rrdbackup']}");
+}
+if (isset($_POST['dhcpbackup'])) {
+ $config['system']['dhcpbackup'] = $_POST['dhcpbackup'];
+ install_cron_job("/etc/rc.backup_dhcpleases.sh", ($config['system']['dhcpbackup'] > 0), $minute="0", "*/{$config['system']['dhcpbackup']}");
+}
+
+
if ($savemsg)
print_info_box($savemsg)
@@ -165,6 +175,49 @@ if ($savemsg)
<tr>
<td valign="top" class="">&nbsp;</td><td><br/><input type='submit' value='Duplicate slice'></form></td>
</tr>
+ <tr>
+ <td colspan="2" valign="top" class="">&nbsp;</td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?=gettext("Periodic Data Backup");?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("RRD Backup");?></td>
+ <td width="78%" class="vtable">
+ <form action="diag_nanobsd.php" method="post" name="iform">
+ <?=gettext("Frequency");?>:
+ <select name='rrdbackup'>
+ <option value='0' <? if (!isset($config['system']['rrdbackup']) || ($config['system']['rrdbackup'] == 0)) echo "selected"; ?>>Disable</option>
+ <? for ($x=1; $x<=24; $x++) { ?>
+ <option value='<?= $x ?>' <? if ($config['system']['rrdbackup'] == $x) echo "selected"; ?>><?= $x ?> hour<? if ($x>1) echo "s"; ?></option>
+ <? } ?>
+ </select>
+ <br/>
+ <?=gettext("This will peridoically backup the RRD data so it can be restored automatically on the next boot. Keep in mind that the more frequent the backup, the more writes will happen to your media.");?>
+ <br/>
+ <br/>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("DHCP Leases Backup");?></td>
+ <td width="78%" class="vtable">
+ <form action="diag_nanobsd.php" method="post" name="iform">
+ <?=gettext("Frequency");?>:
+ <select name='dhcpbackup'>
+ <option value='0' <? if (!isset($config['system']['dhcpbackup']) || ($config['system']['dhcpbackup'] == 0)) echo "selected"; ?>>Disable</option>
+ <? for ($x=1; $x<=24; $x++) { ?>
+ <option value='<?= $x ?>' <? if ($config['system']['dhcpbackup'] == $x) echo "selected"; ?>><?= $x ?> hour<? if ($x>1) echo "s"; ?></option>
+ <? } ?>
+ </select>
+ <br/>
+ <?=gettext("This will peridoically backup the DHCP leases data so it can be restored automatically on the next boot. Keep in mind that the more frequent the backup, the more writes will happen to your media.");?>
+ <br/>
+ <br/>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="">&nbsp;</td><td><br/><input type='submit' value='Save'></form></td>
+ </tr>
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
<tr>
<td colspan="2" valign="top" class="">&nbsp;</td>
OpenPOWER on IntegriCloud