<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>RE: [hobbit] Hobbit migration to a new box</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>-----Original Message-----<BR>
From: Henrik Stoerner [<A HREF="mailto:henrik@hswn.dk">mailto:henrik@hswn.dk</A>]<BR>
Sent: Tue 1/23/2007 10:26 PM<BR>
To: hobbit@hswn.dk<BR>
Subject: Re: [hobbit] Hobbit migration to a new box<BR>
<BR>
On Tue, Jan 23, 2007 at 10:10:58PM +0100, Johann Eggers wrote:<BR>
> From: Henrik Stoerner [<A HREF="mailto:henrik@hswn.dk">mailto:henrik@hswn.dk</A>]<BR>
>> The only real problem one may run into with migrating a Hobbit server is<BR>
>> if you are going from one hardware platform to another - that involves<BR>
>> dump'ing all of the RRD files to XML, and the import'ing all of them<BR>
>> from the XML files onto the new server. It's scriptable, but may take<BR>
>> some time depending on the number of files<BR>
><BR>
> Do you have a handy script for this kind of task and are you willing to share it with the community?<BR>
<BR>
Nothing fancy, but see below. It runs on the old Hobbit server, and uses<BR>
ssh (with ssh-keys to avoid a password prompt for each file) to send the<BR>
XML file across to the new server and import it there.<BR>
<BR>
It also has a list of the per-host RRD directories in /tmp/rrddirs.txt<BR>
(e.g. created by the commented-out "ls -ld ..." command). The trick was<BR>
that I could interrupt the script at any time, and just remove those<BR>
lines from the rrddirs.txt file that had already been processed, then<BR>
restart the script and it would continue.<BR>
<BR>
The reason for first doing an "rm" of the file on the new server was<BR>
that the new server was already being fed updates, so it was creating<BR>
and updating RRD files while this script was running. "rrdtool restore"<BR>
aborts if the file exists, so I had to delete any existing rrd file on<BR>
the new server.<BR>
<BR>
<BR>
Henrik<BR>
<BR>
<BR>
#!/bin/sh<BR>
<BR>
MYNEWSERVER=rrdserver.foo.com<BR>
<BR>
cd /var/lib/hobbit/rrd<BR>
#ls -1d * >/tmp/rrddirs.txt<BR>
<BR>
cat /tmp/rrddirs.txt | while read H<BR>
do<BR>
   NUM=`find $H -type f -a -name "*.rrd" -a -mtime -30 | wc -l`<BR>
   if [ $NUM -gt 0 ]<BR>
   then<BR>
      echo "Processing $H ($NUM files)"<BR>
      find $H -type f -a -name "*.rrd" -a -mtime -30 | while read f<BR>
      do<BR>
         FULLFN="/var/lib/hobbit/rrd/$f"<BR>
         rrdtool dump "$f" | ssh $MYNEWSERVER "rm \"$FULLFN\"; rrdtool restore - \"$FULLFN\""<BR>
      done<BR>
   else<BR>
      echo "Skipped $H - no up-to-date files"<BR>
   fi<BR>
done<BR>
<BR>
exit 0<BR>
<BR>
--------<BR>
Thx!!<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>