Exporting and Importing RRD Files

If you ever need to move binary RRD files between architectures, you need to dump them to XML on the old host and restore them as binary on the new host. The following bash loops do this quickly and simply.

Converting binary RRD files to ASCII XML:

for x in `ls *.rrd`; do
	NAME="$(echo "${x}" | awk 'BEGIN {FS="."} {print $1}')"
	rrdtool dump ${x} > ${NAME}.xml
done

Converting ASCII XML files back to binary RRD:

for x in `ls *.xml`; do
	NAME="$(echo "${x}" | awk 'BEGIN {FS="."} {print $1}')"
	rrdtool restore -f ${x} ${NAME}.rrd
done