How to Backup Zabbix Server?

PowerADM.com / Linux / How to Backup Zabbix Server?

An up-to-date Zabbix Server backup will allow you to quickly restore the monitoring system configuration in case of software failures or hardware failures.

The basic information and configuration of Zabbix Server are stored in a database (the most commonly used is PostgreSQL or MySQL/MariaDB). In the simplest case, you can backup your server by simply exporting the database to a file from mysql/mariadb or postgresql command line.

If you don’t need historical data and want to reduce the size of the Zabbix Server database dump, you can exclude tables with History, Trends, and Events (these tables are named: history, history_uint, history_text, history_str, history_log, trends, trends_uint, events). By excluding these tables, you can reduce the size of your backups by 90%. The list of tables to be ignored can be specified using --ignore-table:

# mysqldump --ignore-table=zabbix.history --ignore-table=zabbix.history_uint --ignore-table=zabbix.trends --ignore-table=zabbix.trends_uint --ignore-table=zabbix.events -u USERNAME -h localhost -pPASSWORD zabbix | gzip -c > /backups/zabbix_`date +%Y-%m-%d`.sql.gz

In addition to backing up the Zabbix database, you can backup configuration files for Zabbix Server, web servers (usually Nginx or Apache) and SSL certificates: /etc/nginx/, /etc/httpd/, /etc/apache2, /etc/zabbix/, /usr/lib/zabbix.

To create an archive with zabbix http files, you can run the command:

# tar -cvjf /backups/`date +%Y-%m-%d`_zabbix.tar.bz2 /usr/share/zabbix/

Also, you can export and import some server items through the Zabbix web interface or API. You can separately export the following configuration items: Hosts, Templates, Media types, Maps, images, Host groups, and Template groups. This will also allow you to quickly transfer hosts from the old Zabbix Server to the new one.

Note. When you back up a database via a dump, we recommend disabling table locks (--single-transaction --skip-lock-tables). Otherwise, the performance of the Zabbix Server during data export may drop significantly.

You can use the zabbix-backup (https://github.com/npotorino/zabbix-backup) to back up the Zabbix Server database. The script allows you to select tables to be added to the backup and supports Zabbix versions from 3.1 to 6.2.

To install the script and perform a backup, run the commands:

git clone https://github.com/npotorino/zabbix-backup
cd zabbix-backup
./zabbix-dump -t psql -H localhost -P 5432 -o /var/backup

backup zabbix server database and configuration files

Hint. You can use Zabbix to monitor your VMware ESXi hosts.

Leave a Reply

Your email address will not be published. Required fields are marked *