Zabbix Database restore

We will be taking mysql database into consideration and will be using mysqldump utility to restore the zabbix database.

In the previous sections we have taken the database backup and we will be using the same zabbix database restore process.

Zabbix Database backup

Restoring Database

In case of any failure we will have to install the fresh mysql database copy with the same version old instance was running to ensure smooth & unintereppted restore process.

sudo apt install mysql-server
sudo systemctl enable mysql
sudo systemctl start mysql

We will need to make some configuration changes to ensure database accepts connection other than the localhost in case when zabbix is deployed on the multinode model.

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Look for the bind-address directive under the [mysqld] section. By default, it may be set to 127.0.0.1 (localhost) to restrict connections to the local machine. Change this to 0.0.0.0 to allow MySQL to listen on all network interfaces.

[mysqld]
bind-address = 0.0.0.0

This will ensure mysql connection from foreign hosts but we need to add some security which we can do with ufw :

sudo ufw allow from <NETWORK_RANGE> to any port 3306
sudo ufw deny from any to any port 3306

Now we will restart the mysql connections to ensure that all settings & configurations are applied correctly.

sudo systemctl restart mysql

⚠️ UFW configuration might disconnect active sessions if not configured correctly.


Creating existing users on the new database

create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@<NETWORK> identified by '<SAME_OLD_DB-password>';

Importing the databse using the mysqldump utility :

mysql -u username -p your_database_name < /path/to/your_backup.sql

Once database is restored we can enable the zabbix-server back to resume normal operations.

sudo systemctl start zabbix-server

Last updated