灌溉梦想,记录脚步
« »
2009 年 11 月 23 日技术合集

linux/centos cacti备份及恢复shell

备份及恢复Cacti
(1)cacti的文件目录的备份(rra目录除外)
(2)mysql备份
mysqldump -p cacti >/tmp/cacti.sql
(3)备份rra
dumprrd.sh

#!/bin/sh
rrddump=”/usr/local/bin/rrdtool dump”
xmldir=”/tmp/mysqlbackup/rraxml”
xmlbackup=”/tmp/mysqlbackup/rrabak”
mysqlbackupDIR=”/tmp/mysqlbackup”
rrdpath=”/usr/local/share/cacti/rra/”
DATE=`date +”%y-%m-%d”`
if [ ! -e {xmldir}
fi
if [ ! -e {xmlbackup}
fi
#create rra => xml
for file in `find /usr/local/share/cacti/rra/ -mtime -2 | awk -F\/ ‘{print $NF}̵7;`
do
{rrdpath}{xmldir}/${file}.xml
done
if [ `ls /tmp/mysqlbackup/rraxml/|wc -l` -ge 2 ];then
#tar backup
cd ${mysqlbackupDIR}
tar czvf {DATE}.tar.gz rraxml >/dev/null 2>&1
mv {DATE}.tar.gz ${xmlbackup}
#delete file&dir
if [ $? -eq 0 ];then
rm -fdr {xmldir}
/usr/bin/find ${mysqlbackupDIR}/rrabak -type f -ctime +2 | /usr/bin/xargs /bin/rm >/dev/null 2>&1
echo “Rra Backup is ok!”
fi
else
echo “Rra Backup is fail!”
fi

恢复Cacti
(1)cacti的文件目录的备份(rra目录除外)
(2)mysql恢复
(3)恢复rra
restorerra.sh

#!/bin/sh
rrdrestore=”/usr/local/bin/rrdtool restore”
xmldir=/tmp/rraxml/
for file in `find NF}217; | sed s/.xml//g`
do
echo {rrdrestore} {file}.xml /usr/local/share/cacti/rra/${file}
done
chown -R cacti:cacti /usr/local/share/cacti/rra

日志信息 »

该日志于2009-11-23 08:49由 kevin 发表在技术合集分类下, 你可以发表评论。除了可以将这个日志以保留源地址及作者的情况下引用到你的网站或博客,还可以通过RSS 2.0订阅这个日志的所有评论。

没有评论

发表评论 »