Skip to content
Oct 7 / Greg

Cacti Video Tutorial – Backups

CactiEZ by default runs a backup script nightly. It dumps these files into a folder. All we have to do is configure our CactiEZ box to send those files elsewhere.

Backup location is /var/www/backup.

The backup script itself is /var/www/backup.sh. I modify the backup script as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#/bin/bash
cd /var/www/
# Remove old backups
find /var/www/backups/* -mtime +5 -exec rm -fr {} \; > /dev/null 2>&1
 
# Remove old RRAs (usually means the datasource is deleted)
find /var/www/html/rra/* -mtime +2 -exec rm -fr {} \; > /dev/null 2>&1
 
# Create the filename for the backup
eval `date "+day=%d; month=%m; year=%Y"`
INSTFIL="cacti-backup-$year-$month-$day.tar.gz"
 
# Dump the MySQL Database
mysqldump -uroot --opt cacti> html/cacti-backup.sql
mysqldump -uroot --ignore-table=syslog.syslog --ignore-table=syslog.syslog_incoming --opt syslog> html/syslog-backup.sql
 
cp /var/www/backup.sh /var/www/html/backup.sh
cp /etc/sysconfig/iptables /var/www/html/iptables
cp /etc/sysconfig/network /var/www/html/network
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /var/www/html/ifcfg-eth0
 
# Gzip the whole folder
tar -Pcpzf backups/$INSTFIL html/*
 
# Remove the SQL Dump
 
rm -f html/cacti-backup.sql
rm -f html/syslog-backup.sql
rm -f html/backup.sh
rm -f html/iptables
rm -f html/network
rm -f html/ifcfg-eth0

The above script adds:
– backup of the script itself
– modifies the syslog database backup so that it only gets our alerts and removals
– backs up the iptables rules
– backs up the eth0 interface configuration

Now for the video tutorial, click the link below!









When you need to actually restore your configuration…what do you do?
Insert your CactiEZ cd and reinstall, if your machine completely died, or you are migrating to a new machine.
Then, copy and paste the backup files over the top of the old files, without overwriting. You will obviously want to overwrite the iptables files and such.
Reimport the SQL files:

  1. mysql cacti < cacti-backup.sql
  2. mysql syslog < syslog-backup.sql

Let me know what you guys think, I need the feedback.

2 Comments

leave a comment
  1. pablo / May 16 2010

    In what directory i restore???????

  2. Greg / May 19 2010

    /var/www/html

Leave a Comment

*