zabbix之备份与恢复(转)

时间:2024-04-06 14:30:39

zabbix前端的所有操作都是存在数据库里的,在数据库里都会有对应的表,所以对zabbix备份,只需备份zabbix数据库就行了。使用最广泛的备份方法还是使用mysqldump。

一:全库备份

[[email protected] ~]# mysqldump -uroot -p123456 --opt zabbix | bzip2 > zabbix.sql.bz2
[[email protected] ~]# ll zabbix.sql.bz2
-rw-r–r-- 1 root root 2353816 10-23 00:54 zabbix.sql.bz2
#–opt Same as --add-drop-table, --add-locks, --create-options,
–quick, --extended-insert, --lock-tables, --set-charset,
and --disable-keys. Enabled by default, disable with
–skip-opt.
#由于zabbix库一般比较大,所以使用bzip2进行压缩

二:分开备份
1.zabbix数据库中有很多的多,大体上分为存放监控数据的表和配置的表两种。
数据表有:
alerts
auditlog
events
history
history_log
history_str
history_str_sync
history_sync
history_text
history_uint
history_uint_sync
node_cksum
proxy_dhistory
proxy_history
service_alarms
services_times
trends
trends_uint

其它的表便是zabbix的配置信息表:

2.备份zabbix的配置表。

[[email protected] ~]# mysqldump -uroot -p123456 --databases zabbix --ignore-table=zabbix.alerts --ignore-table=zabbix.auditlog --ignore-table=zabbix.events --ignore-table=zabbix.history --ignore-table=zabbix.history_log --ignore-table=zabbix.str --ignore-table=zabbix.str_sync --ignore-table=zabbix.sync --ignore-table=zabbix.text --ignore-table=zabbix.uint --ignore-table=zabbix.uint_sync --ignore-table=zabbix.node_cksum --ignore-table=zabbix.proxy_dhistory --ignore-table=zabbix.proxy_history --ignore-table=zabbix.service_alarms --ignore-table=zabbix.services_times --ignore-table=zabbix.trends --ignore-table=zabbix.trends_uint > zabbix_config.sql
[[email protected] ~]# ll zabbix_config.sql
-rw-r–r-- 1 root root 14572182 10-23 01:15 zabbix_config.sql
#使用–ignore-table跳过不需要备份的表

3.把备份文件上传另一主机上,看能否导入生效。

[[email protected] ~]# scp zabbix_config.sql [email protected]:/root/
zabbix_config.sql 100% 14MB 7.0MB/s 00:02

4.导入

[[email protected] ~]# mysql zabbix < zabbix_config.sql

5.前端查看
zabbix之备份与恢复(转)
Zabbix监控 之 数据库备份