This template is designed to analize restic backup json results file and check if backup is properly done.
There are some zabbix restic templates, but usualy requires external tools like resticprofile or shells to actively send data to zabbix from host. This template is designed to work without requiring any external tool or shell and you can automatize your backups using crontab and still check if they are completed succesfully.
The template export file includes two restic backup templates; one for passive mode and the other for active mode. They are equal, and the active template allows to push the log file to the zabbix server when required. you'll need some shell script to get the restic log and push it to server using zabbix_send
Tested on:
- RHEL 10.0
- Zabbix 7.x
- Vicente Salvador Cubedo
- import templates (xml file)
- link restic template to host where the restic backup log is placed.
You can import simple templates or multibackup templates. The method you should use to execute backup changes depending of the template you're using.
Note: I don't delete the simple versión of templates to keep compatibility with users already using this method.
-
install and configure zabbix-agent
dnf install -y zabbix-agent
or install zabbix agent 2 if you're using this new version:
dnf install -y zabbix-agent2 zabbix-agent2-plugin-* -
install required dependencies for shell commands
rpm -q jq || dnf install jq -
reboot zabbix-agent service
systemctl restart zabbix-agent
- you can automatize your restic backup using crontab commands:
you can add to log file the results of several backup commands. Just keep in mind you should provide different profile names.
45 02 * * * bash -l -c "restic --json --quiet backup /folder1 | jq -c '. + {profile: \"maindata\"}' > /var/log/restic_backup.log"
This template is not still available, but we document the method to use it in the future.
- you can automatize your restic backup using crontab commands:
this method keeps always last result of each backup execution in the json object stored in /var/log/restic_backup.log keeping this results in a diferent property for each backup executed.
40 02 * * * bash -l -c "[ -f /var/log/restic_backup.log ] || echo '{}' > /var/log/restic_backup.log" 45 02 * * * bash -l -c "restic --json --quiet backup /folder1 | jq -c --slurpfile input /dev/stdin '. + {maindata: \$input[0]}' /var/log/restic_backup.log > /tmp/$$.restic.log && mv -f /tmp/$$.restic.log /var/log/restic_backup.log" 00 13 * * * bash -l -c "restic --json --quiet backup /folder2 | jq -c --slurpfile input /dev/stdin '. + {auxdata: \$input[0]}' /var/log/restic_backup.log > /tmp/$$.restic.log && mv -f /tmp/$$.restic.log /var/log/restic_backup.log"
- Create a new host to contact zabbix agent on restic backup host
- Link the template to the host created earlier
| Name | Description | Default |
|---|---|---|
| {$BACKUP_STATUS_FILE} | Restic status file | /var/log/restic_backup.log |
| {$MAX_HOURS_BETWEEN} | How many hours between backups to alert. | 26 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Restic status file | Get content of JSON Array file where backup logs are placed |
Zabbix agent |
vfs.file.contents[{$BACKUP_STATUS_FILE}] Update: 1h |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Restic log profiles | Discovery of JSON profiles stored in log file. |
Dependent |
backup.results |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Restic profile {#PROFILENAME} data added | Data added to backup |
Dependent |
restic.data_added[{#PROFILENAME}] |
| Name | Description | Expression | Priority |
|---|---|---|---|
| xxx | - |
Expression: last(/xx/xx)<15m Recovery expression: |
warning |