1
|
#!/bin/sh
|
2
|
|
3
|
: ${RRDDBPATH:=/var/db/rrd}
|
4
|
: ${CF_CONF_PATH:=/cf/conf}
|
5
|
|
6
|
# Save the rrd databases to the config path.
|
7
|
if [ -d "${RRDDBPATH}" ]; then
|
8
|
[ -z "$NO_REMOUNT" ] && /etc/rc.conf_mount_rw
|
9
|
[ -f "${CF_CONF_PATH}/rrd.tgz" ] && /bin/rm -f "${CF_CONF_PATH}"/rrd.tgz
|
10
|
|
11
|
tgzlist=""
|
12
|
|
13
|
for rrdfile in "${RRDDBPATH}"/*.rrd ; do
|
14
|
xmlfile="${rrdfile%.rrd}.xml"
|
15
|
tgzfile="${rrdfile%.rrd}.tgz"
|
16
|
/usr/bin/nice -n20 /usr/local/bin/rrdtool dump "$rrdfile" "$xmlfile"
|
17
|
cd / && /usr/bin/tar -czf "${tgzfile}" -C / "${RRDDBPATH#/}"/*.xml
|
18
|
/bin/rm -f "${RRDDBPATH}"/*.xml
|
19
|
tgzlist="${tgzlist} @${tgzfile}"
|
20
|
done
|
21
|
if [ -n "${tgzlist}" ]; then
|
22
|
cd / && /usr/bin/tar -czf "${CF_CONF_PATH}/rrd.tgz" ${tgzlist}
|
23
|
/bin/rm -f "${RRDDBPATH}"/*.tgz
|
24
|
fi
|
25
|
[ -z "$NO_REMOUNT" ] && /etc/rc.conf_mount_ro
|
26
|
fi
|
27
|
|