Ad Widget

Collapse

Zabbix 1.8 backup without History

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kth5
    Junior Member
    • May 2011
    • 1

    #1

    Zabbix 1.8 backup without History

    Hey everyone,

    I've been looking for a more efficient solution to backup my Zabbix server nodes than to dump the whole database, which in my case is quite large (21G / IBD raw filesize) and I already tended to use trends much earlier than management would like around here.

    Anyway, I came up with a little script:

    #!/bin/bash
    DATE=$(date "+%Y-%m-%d")
    TABLES=$(mysql -u root --database zabbix -e"show tables where Tables_in_zabbix not like '%history%' and Tables_in_zabbix not in ('housekeeper', 'sessions', 'events', 'trends', 'trends_uint');")
    DUMPTABLES=""
    for table in ${TABLES}; do
    [ ! "${table}" = "Tables_in_zabbix" ] && DUMPTABLES="${DUMPTABLES} ${table}"
    done
    mysqldump -u root -d --opt zabbix &>zabbix-struct-${DATE}.sql
    mysqldump -u root --dump-date --single-transaction --opt zabbix ${DUMPTABLES} &>zabbix-config-${DATE}.sql
    It creates to dated files, one with all empty tables and then a file with only the ones who's data needs to be reimportant for an empty but preconfigured Zabbix server.

    My way of finding the relevant tables may seem a bit patchy but I didn't think of a simpler way yet.

    Suggestions are welcome and if you find it useful, that makes me happy!
Working...