Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update zabbix-mysql-backupconf.sh #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions zabbix-mysql-backupconf.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/bin/bash
#
# zabbix-mysql-backupconf.sh
# v0.2 - 20111105
# v0.3 - 2014-July-15
#
# Configuration Backup for Zabbix 1.8 w/MySQL
# Configuration Backup for Zabbix 2.2 w/MySQL
#
# Author: Ricardo Santos (rsantos at gmail.com)
# http://zabbixzone.com
#
# Thanks for suggestions from:
# - Oleksiy Zagorskyi (zalex)
# - Petr Jendrejovsky
# - Dave Orth
#
# v0.3 - Updated with 6 new tables introduced with Zabbix 2.2 and deleted one table no longer present.
# New tables have been placed in CONFTABLES

# mysql config
DBHOST="localhost"
Expand All @@ -31,18 +34,19 @@ DUMPDIR="${MAINDIR}/`${DATEBIN} +%Y%m%d%H%M`"
${MKDIRBIN} -p ${DUMPDIR}

# configuration tables
CONFTABLES=( actions applications autoreg_host conditions config dchecks dhosts \
drules dservices escalations expressions functions globalmacro graph_theme \
graphs graphs_items groups help_items hostmacro hosts hosts_groups \
hosts_profiles hosts_profiles_ext hosts_templates housekeeper httpstep \
httpstepitem httptest httptestitem ids images items items_applications \
maintenances maintenances_groups maintenances_hosts maintenances_windows \
mappings media media_type node_cksum nodes opconditions operations \
opmediatypes profiles proxy_autoreg_host proxy_dhistory proxy_history regexps \
rights screens screens_items scripts service_alarms services services_links \
services_times sessions slides slideshows sysmaps sysmaps_elements \
sysmaps_link_triggers sysmaps_links timeperiods trigger_depends triggers \
user_history users users_groups usrgrp valuemaps )
CONFTABLES=( actions application_template applications autoreg_host conditions config \
dchecks dhosts dbversion drules dservices escalations expressions functions globalmacro \
globalvars graph_discovery graph_theme graphs graphs_items groups group_discovery \
group_prototype host_discovery host_inventory hostmacro hosts hosts_groups hosts_templates \
housekeeper httpstep httpstepitem httptest httptestitem icon_map icon_mapping ids images \
interface interface_discovery item_discovery items items_applications maintenances \
maintenances_groups maintenances_hosts maintenances_windows mappings media media_type \
node_cksum nodes opcommand opcommand_grp opcommand_hst opconditions operations \
opgroup opmessage opmessage_grp opmessage_usr optemplate profiles proxy_autoreg_host \
proxy_dhistory proxy_history regexps rights screens screens_items scripts service_alarms \
services services_links services_times sessions slides slideshows sysmap_element_url \
sysmap_url sysmaps sysmaps_elements sysmaps_link_triggers sysmaps_links timeperiods \
trigger_depends trigger_discovery triggers user_history users users_groups usrgrp valuemaps )

# tables with large data
DATATABLES=( acknowledges alerts auditlog_details auditlog events \
Expand All @@ -52,7 +56,7 @@ history_uint history_uint_sync trends trends_uint )
# CONFTABLES
for table in ${CONFTABLES[*]}; do
DUMPFILE="${DUMPDIR}/${table}.sql"
echo "Backuping table ${table}"
echo "Backing up table ${table}"
${MYSQLDUMP} -R --opt --extended-insert=FALSE \
-h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} --tables ${table} >${DUMPFILE}
${GZIP} -f ${DUMPFILE}
Expand All @@ -61,7 +65,7 @@ done
# DATATABLES
for table in ${DATATABLES[*]}; do
DUMPFILE="${DUMPDIR}/${table}.sql"
echo "Backuping schema table ${table}"
echo "Backing up schema table ${table}"
${MYSQLDUMP} -R --opt --no-data \
-h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} --tables ${table} >${DUMPFILE}
${GZIP} -f ${DUMPFILE}
Expand Down