Резервное копирование Zabbix
Script
/opt/scripts/backup_zabbix_mysql.sh
#!/bin/bash
service zabbix-server stop
mysqldump -uroot -pzabbix zabbix --ignore-table=zabbix.history --ignore-table=zabbix.history_uint \
--ignore-table=zabbix.history_text --ignore-table=zabbix.trends --ignore-table=zabbix.trends_uint | gzip -c > /opt/backup/zabbix_`date +%Y-%m-%d`.sql.gz
tar -cvjf /opt/backup/usr_share_`date +%Y-%m-%d`_zabbix.tar.bz2 /usr/share/zabbix/ /usr/share/mibs/
service zabbix-server start
Cron
/etc/crontab
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
* 22 * * * root /opt/scripts/backup_zabbix_mysql.sh > /opt/backup/log 2>&1
Подробнее расписано тут
Script
/opt/scripts/backup_zabbix_mysql.sh
#!/bin/bash
service zabbix-server stop
mysqldump -uroot -pzabbix zabbix --ignore-table=zabbix.history --ignore-table=zabbix.history_uint \
--ignore-table=zabbix.history_text --ignore-table=zabbix.trends --ignore-table=zabbix.trends_uint | gzip -c > /opt/backup/zabbix_`date +%Y-%m-%d`.sql.gz
tar -cvjf /opt/backup/usr_share_`date +%Y-%m-%d`_zabbix.tar.bz2 /usr/share/zabbix/ /usr/share/mibs/
service zabbix-server start
Cron
/etc/crontab
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
* 22 * * * root /opt/scripts/backup_zabbix_mysql.sh > /opt/backup/log 2>&1
Подробнее расписано тут
No comments:
Post a Comment