summaryrefslogtreecommitdiffstats
path: root/src/etc/rc.backup_rrd.sh
diff options
context:
space:
mode:
authorNOYB <Al_Stu@Frontier.com>2016-04-23 00:03:34 -0700
committerNOYB <Al_Stu@Frontier.com>2017-01-08 19:14:16 -0800
commit257d2fd6750185a52b703cffd9419737f83777ee (patch)
treea8bace8b55ed2b422243cc499726b88d8d33b2b3 /src/etc/rc.backup_rrd.sh
parent286ed246df8bc25df436fd6a5cbc66e38fe5a06a (diff)
downloadpfsense-257d2fd6750185a52b703cffd9419737f83777ee.zip
pfsense-257d2fd6750185a52b703cffd9419737f83777ee.tar.gz
RAM Disk Management
1) Treat the RAM disk more like a permanent storage device with content managed/restored by the system and made available at boot up, before needed by any services. a) Handle saving and restoring RAM disk content at reboot/shutdown/boot centrally in more of a system manged fashion. b) If it's in the RAM disk store it gets restored early in the pfSense startup so it's available for whatever needs to use it. c) Services utilizing RAM disk don't need to be aware that their content is on a RAM disk, and handling content restore individually. 2) Has the benefit of eliminating some issues with the previous code as well. Such as... a) Restoring RRD multiple times during boot, potentially at least 3 times, by rc.newwanip, rc.newwanipv6, and rc.boot. Some even overlapping. b) Not removing the backups if/when not being utilized. Such as on a full install with the RAM disk option not enabled. c) Eliminate some duplicate code. 3) Looking forward. a) The more centrally system managed approach may crack the door open to making it easier to include some of the logs in the RAM disk store. As well as anything else that may be useful/desirable to retain in the RAM disk across reboots.
Diffstat (limited to 'src/etc/rc.backup_rrd.sh')
-rwxr-xr-xsrc/etc/rc.backup_rrd.sh23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/etc/rc.backup_rrd.sh b/src/etc/rc.backup_rrd.sh
index 873652f..ccd5b23 100755
--- a/src/etc/rc.backup_rrd.sh
+++ b/src/etc/rc.backup_rrd.sh
@@ -1,15 +1,23 @@
#!/bin/sh
-: ${RRDDBPATH:=/var/db/rrd}
+: ${DBPATH:=/var/db/rrd}
: ${CF_CONF_PATH:=/cf/conf}
-# Save the rrd databases to the config path.
-if [ -d "${RRDDBPATH}" ]; then
- [ -f "${CF_CONF_PATH}/rrd.tgz" ] && /bin/rm -f "${CF_CONF_PATH}"/rrd.tgz
+: ${RAM_Disk_Store:=${CF_CONF_PATH}/RAM_Disk_Store}
+
+# Save the rrd databases to the RAM disk store.
+if [ -d "${DBPATH}" ]; then
+ echo -n "Saving RRD to RAM disk store...";
+
+ [ -f "${RAM_Disk_Store}/rrd.tgz" ] && /bin/rm -f "${RAM_Disk_Store}"/rrd.tgz
+
+ if [ ! -d "${RAM_Disk_Store}" ]; then
+ mkdir -p "${RAM_Disk_Store}"
+ fi
tgzlist=""
- for rrdfile in "${RRDDBPATH}"/*.rrd ; do
+ for rrdfile in "${DBPATH}"/*.rrd ; do
xmlfile="${rrdfile%.rrd}.xml"
tgzfile="${rrdfile%.rrd}.tgz"
/usr/bin/nice -n20 /usr/local/bin/rrdtool dump "$rrdfile" "$xmlfile"
@@ -20,7 +28,8 @@ if [ -d "${RRDDBPATH}" ]; then
if [ -n "${tgzlist}" ]; then
/usr/bin/tar -czf "${CF_CONF_PATH}/rrd.tgz" -C / ${tgzlist}
- /bin/rm -f "${RRDDBPATH}"/*.tgz
+ /bin/rm -f "${DBPATH}"/*.tgz
fi
-fi
+ echo "done.";
+fi
OpenPOWER on IntegriCloud