脚本不错,记下来备用
#/bin/sh :<< Statement | Function : TO BACK ZABBIX DB EXCEPT HISTORY* TREND* | version : DEV | mail : 714810243@qq.com | date : 2016-07-19 Statement MysqlCMDPath='/usr/bin/mysql' DumpCMDPath='/usr/bin/mysqldump' DumpDBUser='zabbix' DumpDBPasswd='xxxx' DataBaseName=zabbix BackFileDirPath='/home/zabbix/DBBACK' BackFileDirName=`date +%Y%m%d` function MysqlDump() { [ -d ${BackFileDirPath}/${BackFileDirName} ] || mkdir -p ${BackFileDirPath}/${BackFileDirName} Table_Name_All=`${MysqlCMDPath} -u${DumpDBUser} -p${DumpDBPasswd} ${DataBaseName} -e"show tables;" | egrep -v "Tables_in_zabbix|history*|trends*|events*"` for Table_Name in ${Table_Name_All} do ${DumpCMDPath} -q --skip-opt -u${DumpDBUser} -p${DumpDBPasswd} ${DataBaseName} ${Table_Name} > ${BackFileDirPath}/${BackFileDirName}/${Table_Name}.sql done if [ "$?" == 0 ] ; then echo "${BackFileDirName} : BackUp zabbix successed" >> ${BackFileDirPath}/zabbixback.log else echo "${BackFileDirName} : BackUp zabbix not successed" >> ${BackFileDirPath}/zabbixback.log fi rm -rf ${BackFileDirPath}/`date +%Y%m%d --date='7 days ago'` } MysqlDump
转载!
原创文章,作者:dweifng,如若转载,请注明出处:https://blog.ytso.com/273657.html