> For the complete documentation index, see [llms.txt](https://ghoulsec.gitbook.io/ghoulsec-vault/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ghoulsec.gitbook.io/ghoulsec-vault/security-operations/zabbix-nms/zabbix-database-management/zabbix-database-backup.md).

# 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 :&#x20;

```bash
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:

```bash
# 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 :&#x20;

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.

```bash
sudo systemctl stop zabbix-server
```

Then we will take the database backup using the `mysqldump` utility :&#x20;

```bash
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.

```bash
sudo systemctl start zabbix-server
```

***
