My recent babble

Twitter stuff


Flicker stuff

Main | Stone 03.03.03 Vertical Epic Ale, from the Sept. 9th 2009 Stone Vertical Epic Ale Tasting »
Friday
May142010

How to backup, transfer, and restore cacti on a new system; and the beer to have when doing it.

Over about the past month I have started to use cacti to monitor my home network.  During this time two things have happened; one, I have started gather a lot of network data, two, Ubuntu 10.04 was released.  I initially setup my cacti system on Ubuntu Server 9.10, and now wanted to move my cacti setup to a system running Ubuntu Server 10.04.  Installing and setting up cacti on a new install of Ubuntu Server is quite easy, but that would cause me to loose all of my old network traffic data.  With a little bit of time, and research, I was able to figure out how to move the data and graphs to the new system.

My old cacti system was an Ubuntu Server 9.10 32-bit and my new system is an Ubuntu Server 10.04 64-bit, both running on a box via Citrix XenServer 5.6 beta.  Also, since I am only using the default cacti templates I will not cover how to move any templates from the old system to the new system; this is left to your own, or my future, research.

The first thing that you can do is grab a nice easy drinking beer, I would recommend some of the following;
Victory Prima Pils
Dogfish Head 60 Minute IPA
Or maybe even Stone IPA

Keep in mind, you are looking for a beer that is easy drinking, refreshing, and won't distract you, too much, from your task at hand.

On the old cacti system you will need to do three things;
1) Backup the cacti mysql database
2) Backup the cacti rrd data (graphs)
3) Transfer these items to the new system

To do each of these steps, run the following commands on the old cacti system from your user home directory.

To backup the cacti mysql database;
   

sudo mysqldump -p cacti > cacti.mysql


To backup the cacti rrd data;
   
mkdir rra
cd rra
sudo cp /var/lib/cacti/rra/*.rrd ./
sudo chown YOURUSERNAME:YOURUSERNAME *.rrd
for i in *.rrd; do rrdtool dump "$i" "$i".xml; done


Transfer the cacti.mysql file and the rra directory to your user home directory on the new system, my preferred choice is via sftp initiated from the new system.

On the new cacti system you will need to do four things;
1) Install cacti if you already haven't
2) Restore the cacti mysql database
3) Restore the cacti rrd data (graphs)
4) Access your new cacti site

To do each of these steps, run the following commands on the new cacti system from your user home directory.

To install cacti on the new system;
   
sudo apt-get install cacti


To restore the cacti mysql database;
   
sudo mysql -p cacti < cacti.mysql


To restore the cacti rrd data;
   
cd rra
for i in *.xml; do rrdtool restore "$i" "$i".rrd; done
for i in *.rrd.xml.rrd; do mv "$i" `echo "$i" | sed s/.xml.rrd//g`; done
sudo cp *.rrd /var/lib/cacti/rra/
sudo chown www-data:www-data /var/lib/cacti/rra/*.rrd


Access your new cacti site either locally via http://127.0.0.1/cacti if you have a gui installed, or remotely via http://CACTISYSTEMIP/cacti if you are running a headless server.  Once you have access you may be asked if this cacti system is a new install or an upgrade, you will want to select the upgrade option.  Since this is an upgrade the login information should be the same as on the old cacti system.  After you have logged in successfully you should be done and can now go grab another beer to celebrate.

A few good "celebration" beers that I would recommend are;
Arrogant Bastard by Stone Brewing Co. if you are feeling aggressive and "pumped up"
Dogfish Head 90 Minute IPA if you want to relax with something rich and smooth
Trappistes Rochefort 10 if you want something dark, complex, and contemplative

This was put together mostly for my own notes, but I hope that it can also help others.


The NerdyDrunk,
Timothy A. Ingalls

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (2)

Very useful! Thanks!

May 21, 2010 | Unregistered Commenterori_the_kid

ori_the_kid

I am glad that it was helpful, I hope my update makes it easier and quicker for others that may need this information.

The NerdyDrunk,
Timothy A. Ingalls

June 9, 2010 | Registered CommenterTimothy Ingalls

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>