Zabbix Database backup

We can take the backup of the database regularly so that we dont loose data in case of any failure in the production environment. Currently the documentation is for the MySQL database users where we will be taking use of mysqldump utility to take backup & restoring the database.

Here is the syntax of the mysqldump utility to take the database backup :

mysqldump -u [username] -p [database_name] > [backup_file.sql]

To take backups of all database of any specific database we can use the following syntax:

# All databases
mysqldump -u root -p --all-databases > all_databases_backup.sql
# Multiple databases
mysqldump -u root -p database1 database2 > multiple_databases_backup.sql

Now we will cover zabbix database backup configuration :

First we will ensure that there are no database write done on the database when backup is taking place to avoid any data corruptions on the go. For this we will stop the zabbix server for a while.

sudo systemctl stop zabbix-server

Then we will take the database backup using the mysqldump utility :

mysqldump -u [ZABBIX_USERNAME] -p [ZABBIX_DB_NAME] > [backup_file.sql]

Where the ZABBIX_USERNAME & ZABBIX_DB_NAME are the username pair set when installing the zabbix database first time.

Once the database backup complete we can start the service back normal, The database backup could take time depending on the database size.

sudo systemctl start zabbix-server

Last updated