Setup zabbix-server30 » Historie » Version 2
Jeremias Keihsler, 11.02.2019 11:45
| 1 | 1 | Jeremias Keihsler | h1. Install Zabbix Server 3.0.x |
|---|---|---|---|
| 2 | |||
| 3 | h2. preliminary note |
||
| 4 | |||
| 5 | this procedure is based on [[dw_os_cos6:Setup_zabbix-server22]] |
||
| 6 | |||
| 7 | you may also check |
||
| 8 | https://www.zabbix.com/documentation/2.2/manual/installation/install_from_packages |
||
| 9 | |||
| 10 | **this procedure has not yet been used or tested, use with caution** |
||
| 11 | remove this flag as soon as the first installation has succeeded. |
||
| 12 | |||
| 13 | * [[setup_apache| Apache]] |
||
| 14 | * [[setup_mariadb| MariaDB]] |
||
| 15 | |||
| 16 | h2. Server-Install |
||
| 17 | |||
| 18 | <pre><code class="bash"> |
||
| 19 | dnf update |
||
| 20 | dnf install httpd httpd-devel |
||
| 21 | dnf install zabbix30-server-mysql zabbix30-agent zabbix30-web-mysql |
||
| 22 | dnf install mariadb-server |
||
| 23 | systemctl start httpd.service |
||
| 24 | systemctl enable httpd.service |
||
| 25 | systemctl start mariadb.service |
||
| 26 | systemctl enable mariadb.service |
||
| 27 | /usr/bin/mysql_secure_installation |
||
| 28 | mysql -u root -p |
||
| 29 | </code></pre> |
||
| 30 | <pre><code class="bash"> |
||
| 31 | mysql> create database zabbix character set utf8 collate utf8_bin; |
||
| 32 | mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password'; |
||
| 33 | mysql> exit |
||
| 34 | </code></pre> |
||
| 35 | <pre><code class="bash"> |
||
| 36 | cd /usr/share/zabbix-mysql/ |
||
| 37 | mysql -u root -p zabbix < schema.sql |
||
| 38 | mysql -u root -p zabbix < images.sql |
||
| 39 | mysql -u root -p zabbix < data.sql |
||
| 40 | vim /etc/zabbix/zabbix_server.conf |
||
| 41 | </code></pre> |
||
| 42 | <pre> |
||
| 43 | # line 116: uncomment and add DB password for Zabbix |
||
| 44 | DBPassword=password |
||
| 45 | </pre> |
||
| 46 | <pre><code class="bash"> |
||
| 47 | vim /etc/zabbix/zabbix_agentd.conf |
||
| 48 | </code></pre> |
||
| 49 | <pre> |
||
| 50 | # line 133: change to your hostname |
||
| 51 | Hostname=zabbix.server.com |
||
| 52 | </pre> |
||
| 53 | <pre><code class="bash"> |
||
| 54 | vim /etc/php.ini |
||
| 55 | </code></pre> |
||
| 56 | <pre> |
||
| 57 | # line 384: change to Zabbix recommended |
||
| 58 | max_execution_time = 300 |
||
| 59 | |||
| 60 | # line 394: change to Zabbix recommended |
||
| 61 | max_input_time = 300 |
||
| 62 | |||
| 63 | # line 405: change to Zabbix recommended |
||
| 64 | memory_limit = 128M |
||
| 65 | |||
| 66 | # line 672: change to Zabbix recommended |
||
| 67 | post_max_size = 16M |
||
| 68 | |||
| 69 | # line 800: change to Zabbix recommended |
||
| 70 | upload_max_filesize = 2M |
||
| 71 | |||
| 72 | # line 879: uncomment and add your timezone |
||
| 73 | date.timezone = Europe/Vienna |
||
| 74 | </pre> |
||
| 75 | <pre><code class="bash"> |
||
| 76 | systemctl start zabbix-server |
||
| 77 | systemctl enable zabbix-server-mysql |
||
| 78 | systemctl start zabbix-agent |
||
| 79 | systemctl enable zabbix-agent |
||
| 80 | systemctl restart httpd |
||
| 81 | </code></pre> |
||
| 82 | |||
| 83 | h3. Firewall |
||
| 84 | |||
| 85 | if you are going to monitor other systems than the @localhost@ then you have to open ports @10050@ and @10051@ |
||
| 86 | |||
| 87 | <pre><code class="bash"> |
||
| 88 | firewall-cmd --permanent --add-port=10050/tcp |
||
| 89 | firewall-cmd --permanent --add-port=10051/tcp |
||
| 90 | systemctl restart firewalld |
||
| 91 | </code></pre> |
||
| 92 | |||
| 93 | h3. SELinux |
||
| 94 | |||
| 95 | as SELinux prevents the web-client to establish a connection to @localhost:10050@ you will get a wrong indication on Server-Status. Allow access to the server via |
||
| 96 | <pre><code class="bash"> |
||
| 97 | setsebool -P httpd_can_connect_zabbix 1 |
||
| 98 | </code></pre> |
||
| 99 | |||
| 100 | as SELinux prevents zabbix from fetching the SSH-state you will get a wrong indication on SSH-Status. Allow access to the service via |
||
| 101 | <pre><code class="bash"> |
||
| 102 | setsebool -P zabbix_can_network on |
||
| 103 | </code></pre> |
||
| 104 | |||
| 105 | h1. Backup Zabbix config |
||
| 106 | |||
| 107 | is taken from https://github.com/maxhq/zabbix-backup/ |
||
| 108 | |||
| 109 | This script is a simple way to backup all configuration tables (eg. templates, hostgroups, hosts, triggers…) without the history data. |
||
| 110 | |||
| 111 | As the result is very small, is possible run this backup many times per day. |
||
| 112 | |||
| 113 | The backup-script may be invoked by cron |
||
| 114 | |||
| 115 | @/etc/cron.d/zabbix-backup@ |
||
| 116 | <pre> |
||
| 117 | # JKE 2016-04-10 |
||
| 118 | # |
||
| 119 | # minute hour day month dayofweek |
||
| 120 | # m h d m d |
||
| 121 | # - - - - - |
||
| 122 | # | | | | | |
||
| 123 | # | | | | +-day of week (0-7) sunday=0 or 7 |
||
| 124 | # | | | +---month (1-12) |
||
| 125 | # | | +-----day of month (1-31) |
||
| 126 | # | +-------hour (0-23) |
||
| 127 | # +---------min (0-59) |
||
| 128 | # |
||
| 129 | 5 1 * * * root /usr/local/bin/zabbix-mysql-backupconf.sh -p password -o /var/cache/myzabbixdump -r 5 -q |
||
| 130 | </pre> |
||
| 131 | |||
| 132 | @zabbix-mysql-backupconf.sh@ |
||
| 133 | <pre> |
||
| 134 | #!/usr/bin/env bash |
||
| 135 | # |
||
| 136 | # NAME |
||
| 137 | # zabbix-mysql-dump - Configuration Backup for Zabbix with MySQL |
||
| 138 | # |
||
| 139 | 2 | Jeremias Keihsler | # VERSION |
| 140 | # 0.8.2 |
||
| 141 | # |
||
| 142 | 1 | Jeremias Keihsler | # SYNOPSIS |
| 143 | 2 | Jeremias Keihsler | # This is a MySQL configuration backup script for Zabbix 1.x, 2.x and 3.0.x. |
| 144 | 1 | Jeremias Keihsler | # It does a full backup of all configuration tables, but only a schema |
| 145 | # backup of large data tables. |
||
| 146 | # |
||
| 147 | # The script is based on a script by Ricardo Santos |
||
| 148 | # (http://zabbixzone.com/zabbix/backuping-only-the-zabbix-configuration/) |
||
| 149 | # |
||
| 150 | # CONTRIBUTORS |
||
| 151 | # - Ricardo Santos |
||
| 152 | # - Jens Berthold (maxhq) |
||
| 153 | # - Oleksiy Zagorskyi (zalex) |
||
| 154 | # - Petr Jendrejovsky |
||
| 155 | # - Jonathan Bayer |
||
| 156 | # - Andreas Niedermann (dre-) |
||
| 157 | 2 | Jeremias Keihsler | # - Mișu Moldovan (dumol) |
| 158 | 1 | Jeremias Keihsler | # - Daniel Schneller (dschneller) |
| 159 | 2 | Jeremias Keihsler | # - Ruslan Ohitin (ruslan-ohitin) |
| 160 | # - Jonathan Wright (neonardo1) |
||
| 161 | # - msjmeyer |
||
| 162 | 1 | Jeremias Keihsler | # |
| 163 | # AUTHOR |
||
| 164 | # Jens Berthold (maxhq), 2016 |
||
| 165 | 2 | Jeremias Keihsler | # |
| 166 | # LICENSE |
||
| 167 | # This script is released under the MIT License (see LICENSE.txt) |
||
| 168 | 1 | Jeremias Keihsler | |
| 169 | |||
| 170 | # |
||
| 171 | # DEFAULT VALUES |
||
| 172 | 2 | Jeremias Keihsler | # |
| 173 | 1 | Jeremias Keihsler | # DO NOT EDIT THESE VALUES! |
| 174 | # Instead, use command line parameters or a config file to specify options. |
||
| 175 | # |
||
| 176 | DUMPDIR="$PWD" |
||
| 177 | DBHOST="127.0.0.1" |
||
| 178 | DBNAME="zabbix" |
||
| 179 | DBUSER="zabbix" |
||
| 180 | DBPASS="" |
||
| 181 | 2 | Jeremias Keihsler | COMPRESSION="gz" |
| 182 | 1 | Jeremias Keihsler | QUIET="no" |
| 183 | REVERSELOOKUP="yes" |
||
| 184 | GENERATIONSTOKEEP=0 |
||
| 185 | |||
| 186 | # |
||
| 187 | # SHOW HELP |
||
| 188 | # |
||
| 189 | if [ -z "$1" ]; then |
||
| 190 | cat <<EOF |
||
| 191 | USAGE |
||
| 192 | $(basename $BASH_SOURCE) [options] |
||
| 193 | 2 | Jeremias Keihsler | |
| 194 | 1 | Jeremias Keihsler | OPTIONS |
| 195 | -h HOST |
||
| 196 | Hostname/IP of MySQL server. |
||
| 197 | Default: $DBHOST |
||
| 198 | |||
| 199 | -d DATABASE |
||
| 200 | Zabbix database name. |
||
| 201 | Default: $DBNAME |
||
| 202 | |||
| 203 | -u USER |
||
| 204 | MySQL user to access Zabbix database. |
||
| 205 | Default: $DBUSER |
||
| 206 | |||
| 207 | -p PASSWORD |
||
| 208 | MySQL user password (specify "-" for a prompt). |
||
| 209 | Default: no password |
||
| 210 | |||
| 211 | -o DIR |
||
| 212 | Save Zabbix MySQL dumps to DIR. |
||
| 213 | Default: $DUMPDIR |
||
| 214 | |||
| 215 | -c FILE |
||
| 216 | Use FILE for MySQL options (passed via --defaults-extra-file). |
||
| 217 | PLEASE NOTE: |
||
| 218 | mysqldump needs the database to be specified via command line. |
||
| 219 | So the first "database" options found in the config file is |
||
| 220 | used for mysqldump. |
||
| 221 | |||
| 222 | -r NUM |
||
| 223 | Rotate backups while keeping up to NUM generations. |
||
| 224 | Uses filename to match. |
||
| 225 | Default: keep all backups |
||
| 226 | |||
| 227 | 2 | Jeremias Keihsler | -x |
| 228 | Compress using xz instead of gz |
||
| 229 | PLEASE NOTE: |
||
| 230 | xz compression will take much longer and consume more CPU time |
||
| 231 | but the resulting backup will be about half the size of the same |
||
| 232 | sql file compressed using gz. Your mileage may vary. |
||
| 233 | |||
| 234 | -0 |
||
| 235 | Do not compress the sql dump |
||
| 236 | |||
| 237 | 1 | Jeremias Keihsler | -n |
| 238 | Skip reverse lookup of IP address for host. |
||
| 239 | |||
| 240 | -q |
||
| 241 | Quiet mode: no output except for errors (for batch/crontab use). |
||
| 242 | |||
| 243 | EXAMPLES |
||
| 244 | $(basename $BASH_SOURCE) -h 1.2.3.4 -d zabbixdb -u zabbix -p test |
||
| 245 | $(basename $BASH_SOURCE) -u zabbix -p - -o /tmp |
||
| 246 | $(basename $BASH_SOURCE) -c /etc/mysql/mysql.cnf |
||
| 247 | $(basename $BASH_SOURCE) -c /etc/mysql/mysql.cnf -d zabbixdb |
||
| 248 | |||
| 249 | EOF |
||
| 250 | exit 1 |
||
| 251 | 2 | Jeremias Keihsler | fi |
| 252 | 1 | Jeremias Keihsler | |
| 253 | # |
||
| 254 | # PARSE COMMAND LINE ARGUMENTS |
||
| 255 | # |
||
| 256 | DB_GIVEN=0 |
||
| 257 | 2 | Jeremias Keihsler | while getopts ":h:d:u:p:o:r:c:x0qn" opt; do |
| 258 | 1 | Jeremias Keihsler | case $opt in |
| 259 | h) DBHOST="$OPTARG" ;; |
||
| 260 | d) DBNAME="$OPTARG"; DB_GIVEN=1 ;; |
||
| 261 | u) DBUSER="$OPTARG" ;; |
||
| 262 | p) DBPASS="$OPTARG" ;; |
||
| 263 | c) CNFFILE="$OPTARG" ;; |
||
| 264 | o) DUMPDIR="$OPTARG" ;; |
||
| 265 | r) GENERATIONSTOKEEP=$(printf '%.0f' "$OPTARG") ;; |
||
| 266 | 2 | Jeremias Keihsler | x) COMPRESSION="xz" ;; |
| 267 | 0) COMPRESSION="" ;; |
||
| 268 | 1 | Jeremias Keihsler | n) REVERSELOOKUP="no" ;; |
| 269 | q) QUIET="yes" ;; |
||
| 270 | \?) echo "Invalid option: -$OPTARG" >&2; exit 1 ;; |
||
| 271 | :) echo "Option -$OPTARG requires an argument" >&2; exit 1 ;; |
||
| 272 | esac |
||
| 273 | done |
||
| 274 | |||
| 275 | # Password prompt |
||
| 276 | if [ "$DBPASS" = "-" ]; then |
||
| 277 | read -s -p "Enter MySQL password for user '$DBUSER' (input will be hidden): " DBPASS |
||
| 278 | echo "" |
||
| 279 | fi |
||
| 280 | |||
| 281 | # Config file validations |
||
| 282 | if [ ! -z "$CNFFILE" ]; then |
||
| 283 | if [ ! -r "$CNFFILE" ]; then |
||
| 284 | echo "ERROR: Cannot read configuration file $CNFFILE" >&2 |
||
| 285 | exit 1 |
||
| 286 | fi |
||
| 287 | # Database name needs special treatment: |
||
| 288 | # For mysqldump it has to be specified on the command line! |
||
| 289 | # Therefore we need to get it from the config file |
||
| 290 | if [ $DB_GIVEN -eq 0 ]; then |
||
| 291 | DBNAME=$(grep -m 1 ^database= "$CNFFILE" | cut -d= -f2) |
||
| 292 | fi |
||
| 293 | fi |
||
| 294 | |||
| 295 | # |
||
| 296 | # CONSTANTS |
||
| 297 | # |
||
| 298 | 2 | Jeremias Keihsler | SUFFIX=""; test ! -z $COMPRESSION && SUFFIX=".${COMPRESSION}" |
| 299 | |||
| 300 | 1 | Jeremias Keihsler | MYSQL_OPTS=() |
| 301 | [ ! -z "$CNFFILE" ] && MYSQL_OPTS=("${MYSQL_OPTS[@]}" --defaults-extra-file="$CNFFILE") |
||
| 302 | [ ! -z "$DBHOST" ] && MYSQL_OPTS=("${MYSQL_OPTS[@]}" -h $DBHOST) |
||
| 303 | [ ! -z "$DBUSER" ] && MYSQL_OPTS=("${MYSQL_OPTS[@]}" -u $DBUSER) |
||
| 304 | [ ! -z "$DBPASS" ] && MYSQL_OPTS=("${MYSQL_OPTS[@]}" -p"$DBPASS") |
||
| 305 | |||
| 306 | MYSQL_OPTS_BATCH=("${MYSQL_OPTS[@]}" --batch --silent) |
||
| 307 | [ ! -z "$DBNAME" ] && MYSQL_OPTS_BATCH=("${MYSQL_OPTS_BATCH[@]}" -D $DBNAME) |
||
| 308 | |||
| 309 | 2 | Jeremias Keihsler | # Log file for errors |
| 310 | ERRORLOG=$(mktemp) |
||
| 311 | |||
| 312 | 1 | Jeremias Keihsler | # Host name: try reverse lookup if IP is given |
| 313 | DBHOSTNAME="$DBHOST" |
||
| 314 | command -v dig >/dev/null 2>&1 |
||
| 315 | FIND_DIG=$? |
||
| 316 | if [ "$REVERSELOOKUP" == "yes" -a $FIND_DIG -eq 0 ]; then |
||
| 317 | # Try resolving a given host ip |
||
| 318 | newHostname=$(dig +noall +answer -x $DBHOST | sed -r 's/((\S+)\s+)+([^\.]+)\..*/\3/') |
||
| 319 | test \! -z "$newHostname" && DBHOSTNAME="$newHostname" |
||
| 320 | fi |
||
| 321 | |||
| 322 | # |
||
| 323 | # CONFIG DUMP |
||
| 324 | # |
||
| 325 | if [ "$QUIET" == "no" ]; then |
||
| 326 | cat <<-EOF |
||
| 327 | Configuration: |
||
| 328 | - host: $DBHOST ($DBHOSTNAME) |
||
| 329 | - database: $DBNAME |
||
| 330 | - user: $DBUSER |
||
| 331 | - output: $DUMPDIR |
||
| 332 | |||
| 333 | 2 | Jeremias Keihsler | EOF |
| 334 | 1 | Jeremias Keihsler | fi |
| 335 | |||
| 336 | # |
||
| 337 | # FUNCTIONS |
||
| 338 | # |
||
| 339 | |||
| 340 | # Returns TRUE if argument 1 is part of the given array (remaining arguments) |
||
| 341 | elementIn () { |
||
| 342 | local e |
||
| 343 | for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done |
||
| 344 | return 1 |
||
| 345 | } |
||
| 346 | |||
| 347 | # |
||
| 348 | # CHECKS |
||
| 349 | # |
||
| 350 | if [ ! -x /usr/bin/mysqldump ]; then |
||
| 351 | echo "mysqldump not found." >&2 |
||
| 352 | echo "(with Debian, \"apt-get install mysql-client\" will help)" >&2 |
||
| 353 | exit 1 |
||
| 354 | fi |
||
| 355 | |||
| 356 | # |
||
| 357 | # READ TABLE LIST from __DATA__ section at the end of this script |
||
| 358 | 2 | Jeremias Keihsler | # (http://stackoverflow.com/a/3477269/2983301) |
| 359 | 1 | Jeremias Keihsler | # |
| 360 | DATA_TABLES=() |
||
| 361 | while read line; do |
||
| 362 | table=$(echo "$line" | cut -d" " -f1) |
||
| 363 | echo "$line" | cut -d" " -f5 | grep -qi "DATA" |
||
| 364 | test $? -eq 0 && DATA_TABLES+=($table) |
||
| 365 | done < <(sed '0,/^__DATA__$/d' "$BASH_SOURCE" | tr -s " ") |
||
| 366 | |||
| 367 | # paranoid check |
||
| 368 | if [ ${#DATA_TABLES[@]} -lt 5 ]; then |
||
| 369 | echo "ERROR: The number of large data tables configured in this script is less than 5." >&2 |
||
| 370 | exit 1 |
||
| 371 | fi |
||
| 372 | |||
| 373 | # |
||
| 374 | # BACKUP |
||
| 375 | # |
||
| 376 | # Read table list from database |
||
| 377 | [ "$QUIET" == "no" ] && echo "Fetching list of existing tables..." |
||
| 378 | 2 | Jeremias Keihsler | DB_TABLES=$(mysql "${MYSQL_OPTS_BATCH[@]}" -e "SELECT table_name FROM information_schema.tables WHERE table_schema = '$DBNAME'" 2>$ERRORLOG) |
| 379 | if [ $? -ne 0 ]; then echo "ERROR while trying to access database:" 2>&1; cat $ERRORLOG 2>&1; exit 1; fi |
||
| 380 | 1 | Jeremias Keihsler | DB_TABLES=$(echo "$DB_TABLES" | sort) |
| 381 | DB_TABLE_NUM=$(echo "$DB_TABLES" | wc -l) |
||
| 382 | |||
| 383 | # Query Zabbix database version |
||
| 384 | VERSION="" |
||
| 385 | 2 | Jeremias Keihsler | DB_VER=$(mysql "${MYSQL_OPTS_BATCH[@]}" -N -e "select optional from dbversion;" 2>/dev/null) |
| 386 | 1 | Jeremias Keihsler | if [ $? -eq 0 ]; then |
| 387 | # version string is like: 02030015 |
||
| 388 | re='(.*)([0-9]{2})([0-9]{4})' |
||
| 389 | if [[ $DB_VER =~ $re ]]; then |
||
| 390 | VERSION="_db-${BASH_REMATCH[1]}.$(( ${BASH_REMATCH[2]} + 0 )).$(( ${BASH_REMATCH[3]} + 0 ))" |
||
| 391 | fi |
||
| 392 | fi |
||
| 393 | |||
| 394 | # Assemble file name |
||
| 395 | DUMPFILENAME_PREFIX="zabbix_cfg_${DBHOSTNAME}" |
||
| 396 | DUMPFILEBASE="${DUMPFILENAME_PREFIX}_$(date +%Y%m%d-%H%M)${VERSION}.sql" |
||
| 397 | DUMPFILE="$DUMPDIR/$DUMPFILEBASE" |
||
| 398 | |||
| 399 | PROCESSED_DATA_TABLES=() |
||
| 400 | i=0 |
||
| 401 | |||
| 402 | mkdir -p "${DUMPDIR}" |
||
| 403 | |||
| 404 | [ "$QUIET" == "no" ] && echo "Starting table backups..." |
||
| 405 | while read table; do |
||
| 406 | # large data tables: only store schema |
||
| 407 | if elementIn "$table" "${DATA_TABLES[@]}"; then |
||
| 408 | dump_opt="--no-data" |
||
| 409 | PROCESSED_DATA_TABLES+=($table) |
||
| 410 | # configuration tables: full dump |
||
| 411 | else |
||
| 412 | dump_opt="--extended-insert=FALSE" |
||
| 413 | fi |
||
| 414 | |||
| 415 | mysqldump "${MYSQL_OPTS[@]}" \ |
||
| 416 | --routines --opt --single-transaction --skip-lock-tables \ |
||
| 417 | $dump_opt \ |
||
| 418 | 2 | Jeremias Keihsler | $DBNAME --tables ${table} >> "$DUMPFILE" 2>$ERRORLOG |
| 419 | 1 | Jeremias Keihsler | |
| 420 | 2 | Jeremias Keihsler | if [ $? -ne 0 ]; then echo -e "\nERROR: Could not backup table ${table}:" >&2; cat $ERRORLOG >&2; exit 1; fi |
| 421 | |||
| 422 | 1 | Jeremias Keihsler | if [ "$QUIET" == "no" ]; then |
| 423 | # show percentage |
||
| 424 | i=$((i+1)); i_percent=$(($i * 100 / $DB_TABLE_NUM)) |
||
| 425 | if [ $(($i_percent % 12)) -eq 0 ]; then |
||
| 426 | echo -n "${i_percent}%" |
||
| 427 | else |
||
| 428 | if [ $(($i_percent % 2)) -eq 0 ]; then echo -n "."; fi |
||
| 429 | fi |
||
| 430 | fi |
||
| 431 | 2 | Jeremias Keihsler | done <<<"$DB_TABLES" |
| 432 | 1 | Jeremias Keihsler | |
| 433 | 2 | Jeremias Keihsler | rm $ERRORLOG |
| 434 | |||
| 435 | 1 | Jeremias Keihsler | # |
| 436 | # COMPRESS BACKUP |
||
| 437 | # |
||
| 438 | if [ "$QUIET" == "no" ]; then |
||
| 439 | echo -e "\n" |
||
| 440 | echo "For the following large tables only the schema (without data) was stored:" |
||
| 441 | for table in "${PROCESSED_DATA_TABLES[@]}"; do echo " - $table"; done |
||
| 442 | 2 | Jeremias Keihsler | |
| 443 | echo |
||
| 444 | 1 | Jeremias Keihsler | echo "Compressing backup file..." |
| 445 | fi |
||
| 446 | 2 | Jeremias Keihsler | |
| 447 | EXITCODE=0 |
||
| 448 | if [ "$COMPRESSION" == "gz" ]; then gzip -f "$DUMPFILE"; EXITCODE=$?; fi |
||
| 449 | if [ "$COMPRESSION" == "xz" ]; then xz -f "$DUMPFILE"; EXITCODE=$?; fi |
||
| 450 | if [ $EXITCODE -ne 0 ]; then |
||
| 451 | 1 | Jeremias Keihsler | echo -e "\nERROR: Could not compress backup file, see previous messages" >&2 |
| 452 | exit 1 |
||
| 453 | fi |
||
| 454 | |||
| 455 | 2 | Jeremias Keihsler | [ "$QUIET" == "no" ] && echo -e "\nBackup Completed:\n${DUMPFILE}${SUFFIX}" |
| 456 | 1 | Jeremias Keihsler | |
| 457 | # |
||
| 458 | # ROTATE OLD BACKUPS |
||
| 459 | # |
||
| 460 | if [ $GENERATIONSTOKEEP -gt 0 ]; then |
||
| 461 | [ "$QUIET" == "no" ] && echo "Removing old backups, keeping up to $GENERATIONSTOKEEP" |
||
| 462 | REMOVE_OLD_CMD="cd \"$DUMPDIR\" && ls -t \"${DUMPFILENAME_PREFIX}\"* | /usr/bin/awk \"NR>${GENERATIONSTOKEEP}\" | xargs rm -f " |
||
| 463 | eval ${REMOVE_OLD_CMD} |
||
| 464 | if [ $? -ne 0 ]; then |
||
| 465 | echo "ERROR: Could not rotate old backups" >&2 |
||
| 466 | exit 1 |
||
| 467 | fi |
||
| 468 | fi |
||
| 469 | |||
| 470 | exit 0 |
||
| 471 | |||
| 472 | ################################################################################ |
||
| 473 | # List of all known table names and a flag indicating data (=large) tables |
||
| 474 | # |
||
| 475 | |||
| 476 | __DATA__ |
||
| 477 | 2 | Jeremias Keihsler | acknowledges 1.3.1 - 3.0.3 DATA |
| 478 | actions 1.3.1 - 3.0.3 |
||
| 479 | alerts 1.3.1 - 3.0.3 DATA |
||
| 480 | application_discovery 2.5.0 - 3.0.3 |
||
| 481 | application_prototype 2.5.0 - 3.0.3 |
||
| 482 | application_template 2.1.0 - 3.0.3 |
||
| 483 | applications 1.3.1 - 3.0.3 |
||
| 484 | auditlog 1.3.1 - 3.0.3 DATA |
||
| 485 | auditlog_details 1.7 - 3.0.3 DATA |
||
| 486 | autoreg 1.3.1 - 1.3.4 |
||
| 487 | autoreg_host 1.7 - 3.0.3 |
||
| 488 | conditions 1.3.1 - 3.0.3 |
||
| 489 | config 1.3.1 - 3.0.3 |
||
| 490 | dbversion 2.1.0 - 3.0.3 |
||
| 491 | dchecks 1.3.4 - 3.0.3 |
||
| 492 | dhosts 1.3.4 - 3.0.3 |
||
| 493 | drules 1.3.4 - 3.0.3 |
||
| 494 | dservices 1.3.4 - 3.0.3 |
||
| 495 | escalations 1.5.3 - 3.0.3 |
||
| 496 | events 1.3.1 - 3.0.3 DATA |
||
| 497 | expressions 1.7 - 3.0.3 |
||
| 498 | functions 1.3.1 - 3.0.3 |
||
| 499 | globalmacro 1.7 - 3.0.3 |
||
| 500 | globalvars 1.9.6 - 3.0.3 |
||
| 501 | graph_discovery 1.9.0 - 3.0.3 |
||
| 502 | graph_theme 1.7 - 3.0.3 |
||
| 503 | graphs 1.3.1 - 3.0.3 |
||
| 504 | graphs_items 1.3.1 - 3.0.3 |
||
| 505 | group_discovery 2.1.4 - 3.0.3 |
||
| 506 | group_prototype 2.1.4 - 3.0.3 |
||
| 507 | groups 1.3.1 - 3.0.3 |
||
| 508 | help_items 1.3.1 - 2.1.8 |
||
| 509 | history 1.3.1 - 3.0.3 DATA |
||
| 510 | history_log 1.3.1 - 3.0.3 DATA |
||
| 511 | history_str 1.3.1 - 3.0.3 DATA |
||
| 512 | history_str_sync 1.3.1 - 2.2.13 DATA |
||
| 513 | history_sync 1.3.1 - 2.2.13 DATA |
||
| 514 | history_text 1.3.1 - 3.0.3 DATA |
||
| 515 | history_uint 1.3.1 - 3.0.3 DATA |
||
| 516 | history_uint_sync 1.3.1 - 2.2.13 DATA |
||
| 517 | host_discovery 2.1.4 - 3.0.3 |
||
| 518 | host_inventory 1.9.6 - 3.0.3 |
||
| 519 | host_profile 1.9.3 - 1.9.5 |
||
| 520 | hostmacro 1.7 - 3.0.3 |
||
| 521 | hosts 1.3.1 - 3.0.3 |
||
| 522 | hosts_groups 1.3.1 - 3.0.3 |
||
| 523 | hosts_profiles 1.3.1 - 1.9.2 |
||
| 524 | hosts_profiles_ext 1.6 - 1.9.2 |
||
| 525 | hosts_templates 1.3.1 - 3.0.3 |
||
| 526 | housekeeper 1.3.1 - 3.0.3 |
||
| 527 | httpstep 1.3.3 - 3.0.3 |
||
| 528 | httpstepitem 1.3.3 - 3.0.3 |
||
| 529 | httptest 1.3.3 - 3.0.3 |
||
| 530 | httptestitem 1.3.3 - 3.0.3 |
||
| 531 | icon_map 1.9.6 - 3.0.3 |
||
| 532 | icon_mapping 1.9.6 - 3.0.3 |
||
| 533 | ids 1.3.3 - 3.0.3 |
||
| 534 | images 1.3.1 - 3.0.3 |
||
| 535 | interface 1.9.1 - 3.0.3 |
||
| 536 | interface_discovery 2.1.4 - 3.0.3 |
||
| 537 | item_application_prototype 2.5.0 - 3.0.3 |
||
| 538 | item_condition 2.3.0 - 3.0.3 |
||
| 539 | item_discovery 1.9.0 - 3.0.3 |
||
| 540 | items 1.3.1 - 3.0.3 |
||
| 541 | items_applications 1.3.1 - 3.0.3 |
||
| 542 | maintenances 1.7 - 3.0.3 |
||
| 543 | maintenances_groups 1.7 - 3.0.3 |
||
| 544 | maintenances_hosts 1.7 - 3.0.3 |
||
| 545 | maintenances_windows 1.7 - 3.0.3 |
||
| 546 | mappings 1.3.1 - 3.0.3 |
||
| 547 | media 1.3.1 - 3.0.3 |
||
| 548 | media_type 1.3.1 - 3.0.3 |
||
| 549 | node_cksum 1.3.1 - 2.2.13 |
||
| 550 | node_configlog 1.3.1 - 1.4.7 |
||
| 551 | nodes 1.3.1 - 2.2.13 |
||
| 552 | opcommand 1.9.4 - 3.0.3 |
||
| 553 | opcommand_grp 1.9.2 - 3.0.3 |
||
| 554 | opcommand_hst 1.9.2 - 3.0.3 |
||
| 555 | opconditions 1.5.3 - 3.0.3 |
||
| 556 | operations 1.3.4 - 3.0.3 |
||
| 557 | opgroup 1.9.2 - 3.0.3 |
||
| 558 | opinventory 3.0.0 - 3.0.3 |
||
| 559 | opmediatypes 1.7 - 1.8.22 |
||
| 560 | opmessage 1.9.2 - 3.0.3 |
||
| 561 | opmessage_grp 1.9.2 - 3.0.3 |
||
| 562 | opmessage_usr 1.9.2 - 3.0.3 |
||
| 563 | optemplate 1.9.2 - 3.0.3 |
||
| 564 | profiles 1.3.1 - 3.0.3 |
||
| 565 | proxy_autoreg_host 1.7 - 3.0.3 |
||
| 566 | proxy_dhistory 1.5 - 3.0.3 |
||
| 567 | proxy_history 1.5.1 - 3.0.3 |
||
| 568 | regexps 1.7 - 3.0.3 |
||
| 569 | rights 1.3.1 - 3.0.3 |
||
| 570 | screen_user 3.0.0 - 3.0.3 |
||
| 571 | screen_usrgrp 3.0.0 - 3.0.3 |
||
| 572 | screens 1.3.1 - 3.0.3 |
||
| 573 | screens_items 1.3.1 - 3.0.3 |
||
| 574 | scripts 1.5 - 3.0.3 |
||
| 575 | service_alarms 1.3.1 - 3.0.3 |
||
| 576 | services 1.3.1 - 3.0.3 |
||
| 577 | services_links 1.3.1 - 3.0.3 |
||
| 578 | services_times 1.3.1 - 3.0.3 |
||
| 579 | sessions 1.3.1 - 3.0.3 |
||
| 580 | slides 1.3.4 - 3.0.3 |
||
| 581 | slideshow_user 3.0.0 - 3.0.3 |
||
| 582 | slideshow_usrgrp 3.0.0 - 3.0.3 |
||
| 583 | slideshows 1.3.4 - 3.0.3 |
||
| 584 | sysmap_element_url 1.9.0 - 3.0.3 |
||
| 585 | sysmap_url 1.9.0 - 3.0.3 |
||
| 586 | sysmap_user 3.0.0 - 3.0.3 |
||
| 587 | sysmap_usrgrp 3.0.0 - 3.0.3 |
||
| 588 | sysmaps 1.3.1 - 3.0.3 |
||
| 589 | sysmaps_elements 1.3.1 - 3.0.3 |
||
| 590 | sysmaps_link_triggers 1.5 - 3.0.3 |
||
| 591 | sysmaps_links 1.3.1 - 3.0.3 |
||
| 592 | timeperiods 1.7 - 3.0.3 |
||
| 593 | trends 1.3.1 - 3.0.3 DATA |
||
| 594 | trends_uint 1.5 - 3.0.3 DATA |
||
| 595 | trigger_depends 1.3.1 - 3.0.3 |
||
| 596 | trigger_discovery 1.9.0 - 3.0.3 |
||
| 597 | triggers 1.3.1 - 3.0.3 |
||
| 598 | user_history 1.7 - 2.4.8 |
||
| 599 | users 1.3.1 - 3.0.3 |
||
| 600 | users_groups 1.3.1 - 3.0.3 |
||
| 601 | usrgrp 1.3.1 - 3.0.3 |
||
| 602 | valuemaps 1.3.1 - 3.0.3 |
||
| 603 | 1 | Jeremias Keihsler | </pre> |