RRD migration to different architecture

I have this old machine with an Atom CPU where I installed Debian in 2011 and it’s been running ever since (I just upgrade it to the next major version every two years). One time, I had to replace failing power supply but other than that, it’s been running without any issues ever since. Over time, it’s been used for various purposes, most of them can be performed by a Raspberry these days but why throw something away if it works.

But of course, the fifteen year old Atom CPU D510 can’t do too much heavy lifting these days so while the machine still serves its purpose like storing some offsite backups, I recently decided to move some of the functionality from this machine somewhere else to allow it to catch some breath.

One of those were a bunch of RRD graphs in which I was storing some metrics. But when I moved those somewhere else, the graphs simply wouldn’t display. To my great surprise, I found out that RRD format is architecture sensitive. Even though the CPU is 64-bit, this old Atom box of mine is running a 32-bit system, I don’t really remember why but the system has just 2 GB of RAM and I guess back in 2011 when I was installing it, it wouldn’t been too uncommon to pick the 32-bit version for such a machine.

Anyway, as a result, when I simply took the RRD graphs and moved them somewhere else (somewhere else was 64-bit naturally these days), it didn’t work. What I had to do was to dump all the RRD files to the arch-agnostic XML format on my old 32-bit box (please be aware of the rm part that removes the RRD files, best try it on a copy of the data):

for i in `find . -type f -name "*.rrd"`; do rrdtool dump $i > $(dirname $i)/$(basename -s '.rrd' $i).xml; rm $i; done

Then migrate those dumps over and convert them back from XML to RRD on the new 64-bit box:

for i in `find . -type f -name "*.xml"`; do rrdtool restore $i $(dirname $i)/$(basename -s '.xml' $i).rrd; rm $i; done

Now the RRD files would work on the new system as well.