Project

General

Profile

« Previous | Next » 

Revision 8676899f

Added by Phil Davis over 10 years ago

Process RRD backup compression in var

Prior to this the RRD xml files were added uncompressed to the archive in /cf/conf and then that archive was compressed at the end.
My /cf partition is only 50MB. The uncompressed archive of all the xml files is already 35MB. With a few config backups, or a few more VLANs (xml files) I will soon run into the 50MB limit.
This change creates each xml from rrd one at a time, then compresses that 1 xml into a tgz in /var/db/rrd, deletes the xml then loops to the next rrd file.
At the end of the loop, there are a bunch of /var/db/rrd/*.tgz files, which are small (they take up <2MB on my system, from XMLs that total 35MB). They are then unpacked and put into 1 /cf/conf/rrd.tgz in a single command.
Thus there is no time when 35MB of xml content has to be stored anywhere.
This should work for systems with a lot of RRD files that turn into XML and then TGZ one at a time.

View differences:

etc/rc.backup_rrd.sh
7 7
if [ -d "${RRDDBPATH}" ]; then
8 8
	[ -z "$NO_REMOUNT" ] && /etc/rc.conf_mount_rw
9 9
	[ -f "${CF_CONF_PATH}/rrd.tgz" ] && /bin/rm -f "${CF_CONF_PATH}"/rrd.tgz
10
		
10
	
11
	tgzlist=""
12

  
11 13
	for rrdfile in "${RRDDBPATH}"/*.rrd ; do
12 14
		xmlfile="${rrdfile%.rrd}.xml"
15
		tgzfile="${rrdfile%.rrd}.tgz"
13 16
		/usr/bin/nice -n20 /usr/local/bin/rrdtool dump "$rrdfile" "$xmlfile"
14
		cd / && /usr/bin/tar -rf "${CF_CONF_PATH}"/rrd.tar -C / "${RRDDBPATH#/}"/*.xml
17
		cd / && /usr/bin/tar -czf "${tgzfile}" -C / "${RRDDBPATH#/}"/*.xml
15 18
		/bin/rm -f "${RRDDBPATH}"/*.xml
19
		tgzlist="${tgzlist} @${tgzfile}"
16 20
	done
17
	if [ -f "${CF_CONF_PATH}/rrd.tar" ]; then
18
		/usr/bin/gzip "${CF_CONF_PATH}/rrd.tar"
19
		/bin/mv "${CF_CONF_PATH}/rrd.tar.gz" "${CF_CONF_PATH}/rrd.tgz"
21
	if [ -n "${tgzlist}" ]; then
22
		cd / && /usr/bin/tar -czf "${CF_CONF_PATH}/rrd.tgz" ${tgzlist}
23
		/bin/rm -f "${RRDDBPATH}"/*.tgz
20 24
	fi
21 25
	[ -z "$NO_REMOUNT" ] && /etc/rc.conf_mount_ro
22 26
fi

Also available in: Unified diff