-
Notifications
You must be signed in to change notification settings - Fork 0
/
backupDBConfig.sh
59 lines (53 loc) · 1.99 KB
/
backupDBConfig.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
# SCRIPT DE BACKUP DAS CONFIG DO ZABBIX
# VERSAO 2.x e 3.x
# ESCRITO POR SANSAO
#
# Copyright (C) <2016>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Contacts:
# Eracydes Carvalho (Sansão Simonton) - NOC Analyst - [email protected]
export DBNAME=zabbix
export DBUSER=zabbix
export DBPASS=zabbix
export BK_DEST=/home/zabbix/database
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/zabbix-server stop
sudo /etc/init.d/zabbix-agent stop
sudo mkdir -p "$BK_DEST"
# zabbix schema
mysqldump -u"$DBUSER" -p"$DBPASS" -B "$DBNAME" --no-data > "$BK_DEST/$DBNAME-0-schema.sql"
# zabbix config
mysqldump -u"$DBUSER" -p"$DBPASS" -B "$DBNAME" --single-transaction --quick --no-create-info --no-create-db \
--ignore-table="$DBNAME".acknowledges \
--ignore-table="$DBNAME".alerts \
--ignore-table="$DBNAME".auditlog \
--ignore-table="$DBNAME".auditlog_details \
--ignore-table="$DBNAME".events \
--ignore-table="$DBNAME".history \
--ignore-table="$DBNAME".history_log \
--ignore-table="$DBNAME".history_str \
--ignore-table="$DBNAME".history_str_sync \
--ignore-table="$DBNAME".history_sync \
--ignore-table="$DBNAME".history_text \
--ignore-table="$DBNAME".history_uint \
--ignore-table="$DBNAME".history_uint_sync \
--ignore-table="$DBNAME".trends \
--ignore-table="$DBNAME".trends_uint \
> "$BK_DEST/$DBNAME-1-config.sql"
sudo /etc/init.d/apache2 start
sudo /etc/init.d/zabbix-server start
sudo /etc/init.d/zabbix-agent start