---
title: "Send email based on backup joblog keyword"
published_at: "2023-06-15T15:04:35+00:00"
modified_at: "2023-06-15T15:04:35+00:00"
url: "https://www.baculasystems.com/technical-blog/send-email-based-on-backup-joblog-keyword/"
markdown_url: "https://www.baculasystems.com/technical-blog/send-email-based-on-backup-joblog-keyword.md"
---

[Home](https://www.baculasystems.com/)
 > [Technical Blog](https://www.baculasystems.com/technical-blog/)
 > Send email based on backup joblog keyword

# Send email based on backup joblog keyword

Updated 15th June 2023, Rob Morrison

Here’s a handy tip that you may find useful: In order to grep for a key word in the backup joblog and send an email to a selected recipient, we suggest using a script that will grep a keyword (in this example we use the “Will not descend” keyword). Then send the e-mail (in this case to the recipient specified in the “Mail” directive) or any specific e-mail you wish to use.

For example, in the Messages resource, you should have two “MailCommand” directives. One of them will call the script:

—–8<—–  
 Messages {  
 Name = Default  
 MailCommand = “/opt/bacula/scripts/send_email.sh %j %t %e %c %l %r”  
 MailCommand = “/opt/bacula/bin/bsmtp -h localhost -f \”\(Bacula\) \<%r\>\” -s \”Bacula: %t %e of %c %l\” %r”  
 OperatorCommand = “/opt/bacula/bin/bsmtp -h localhost -f \”\(Bacula\) \<%r\>\” -s \”Bacula: Intervention needed for %j\” %r”  
 Mail = root@localhost,xx.yyyy@baculasystems.com = All, !Skipped  
 Operator = root@localhost = Mount  
 Console = All, !Skipped, !Saved  
 Append = “/opt/bacula/log/bacula.log” = All, !Skipped  
 Catalog = All  
 }

******************

# cat ../scripts/send_email.sh  
 #!/bin/bash

jobid=$1  
 jobtype=$2  
 jobexitstatus=$3  
 jobclient=$4  
 joblevel=$5  
 recipient=$6

joblog=$(echo “llist joblog jobid=$jobid” | /opt/bacula/bin/bconsole)  
 has_warning=$(echo “$joblog” | grep “Will not descend”)  
 echo “$has_warning”  
 if [[ ! -z “$has_warning” ]]; then  
 echo “$joblog” | /opt/bacula/bin/bsmtp -h localhost -s “Backup reported \”Will not descend\”: $jobtype $jobexitstatus of $jobclient $joblevel” $recipient  
 fi  
 —–8<—–

If you wish to send these e-mails to a different recipient, you can simply add it in the MailCommand line as an argument to the script:

—–8<—–

MailCommand = “/opt/bacula/scripts/send_email.sh %j %t %e %c %l support@example.com”  
 —–8<—–

All the above can be customized with any option for character substitution.

Hope that is helpful. Next technical blog coming your way soon!

About the author

[https://www.linkedin.com/in/rob-morrison-3aa443/](https://www.linkedin.com/in/rob-morrison-3aa443/)

Rob Morrison is the marketing director at Bacula Systems. He started his IT marketing career with Silicon Graphics in Switzerland, performing strongly in various marketing management roles for almost 10 years. In the next 10 years Rob also held various marketing management positions in JBoss, Red Hat and Pentaho ensuring market share growth for these well-known companies. He is a graduate of Plymouth University and holds an Honours Digital Media and Communications degree, and completed an Overseas Studies Program.

*Related posts*

[https://www.baculasystems.com/blog/backup-encryption-101/](https://www.baculasystems.com/blog/backup-encryption-101/)
[Backup Encryption 101: Guidelines & Best Practices](https://www.baculasystems.com/blog/backup-encryption-101/)

December 12, 2023

[https://www.baculasystems.com/blog/iec-62443-security-standard/](https://www.baculasystems.com/blog/iec-62443-security-standard/)
[IEC 62443 Security Guide and Standards: Understanding the IEC 62443 Standard and Security Levels](https://www.baculasystems.com/blog/iec-62443-security-standard/)

April 9, 2026

[https://www.baculasystems.com/blog/beegfs-backup/](https://www.baculasystems.com/blog/beegfs-backup/)
[Advanced BeeGFS Backup Strategies for Parallel File System Protection](https://www.baculasystems.com/blog/beegfs-backup/)

May 18, 2026

[https://www.baculasystems.com/blog/proxmox-backup/](https://www.baculasystems.com/blog/proxmox-backup/)
[How to Backup Proxmox? Proxmox VM Backup and Recovery Methods](https://www.baculasystems.com/blog/proxmox-backup/)

May 29, 2024

[https://www.baculasystems.com/blog/ransomware-backup-strategy/](https://www.baculasystems.com/blog/ransomware-backup-strategy/)
[Ransomware Backup Strategies and Best Practices. How to Protect Backups from Ransomware?](https://www.baculasystems.com/blog/ransomware-backup-strategy/)

October 13, 2025

[https://www.baculasystems.com/blog/glusterfs-backup-restore/](https://www.baculasystems.com/blog/glusterfs-backup-restore/)
[GlusterFS Backup and Restore: Snapshots, Replication, and Configuration](https://www.baculasystems.com/blog/glusterfs-backup-restore/)

November 28, 2025
