Ad Widget

Collapse

Zabbix Database Cleanup and backup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vlam
    Senior Member
    Zabbix Certified Specialist
    • Jun 2009
    • 166

    #1

    Zabbix Database Cleanup and backup

    Hi

    Has anyone had any success in doing a backup of all Zabbix data in MySQL database older than "a certain amount of days" but att he same time remove that data out of the database.

    Please I have a fiew systems where we are running on high Database usage.

    Thanks
    4 Zabbix Frontend Servers (Load balanced)
    2 Zabbix App Servers (HA)
    2 Zabbix Database Servers (HA)
    18 Zabbix Proxy Servers (HA)
    3897 Deployed Zabbix Agents
    6161 Values per second
    X-Layer Integration
    Jaspersoft report Servers (HA)
  • soulhunter
    Junior Member
    • Aug 2009
    • 22

    #2
    Originally posted by vlam
    Hi

    Has anyone had any success in doing a backup of all Zabbix data in MySQL database older than "a certain amount of days" but att he same time remove that data out of the database.

    Please I have a fiew systems where we are running on high Database usage.

    Thanks
    I do not use MySQL (running on PostgreSQL), but I think you could partition the tables by date, then you can backup the older partitions and delete them.

    Comment

    • SangOr
      Junior Member
      • Jun 2014
      • 11

      #3
      Yes you can

      USER=
      PASSWD=
      BASE='zabbix'

      DATE = `date "+%Y-%m-%d"`
      service zabbix-server stop
      mkdir /home/zabbix/backupDB

      mysqldump -u$USER -p$PASSWD $BASE > /home/zabbix/backupDB/backup_Zabbix_$DATE.sql

      service zabbix-server start
      And restore with :
      USER=
      PASSWD=
      BASE='zabbix'

      DATE = `date "+%Y-%m-%d"`

      service zabbix-server stop

      mysql -u$USER -p$PASSWD $BASE < /home/zabbix/backupDB/backup_Zabbix_$DATE.sql

      service zabbix-server start
      U can create an other variable for the first script :

      $PREV =`date -d '3days ago' "+%Y-%m-%d"`
      and add this line at the end of script :

      rm -f /home/zabbix/backupDB/backup_Zabbix_$PREV.sql
      After, u can edit /etc/crontab for execute automatically your script each day

      I hope that I helped u and sorry for my english.

      Comment

      Working...