Skip to content

jamerk/Borgmatic-Mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Borgmatic Mailer

This is currently broken, I'll fix it soon

This is a set of scripts to notify you via email if your Borgmatic-run Borg backups failed or not. It will also send the log so you can see the size of your backup and other details.

This could probably all be in one bash script but I was writing it quickly cause I am super not cool with no notifications for my backups.

Written entirely in bash

Requirements

msmtp package
A working borgmatic job
An SMTP server (I use gmail)

Credits

https://hostpresto.com/community/tutorials/how-to-send-email-from-the-command-line-with-msmtp-and-mutt/
https://guides.codechewing.com/bash/conditionally-assign-value-to-variable-bash
https://github.com/witten/borgmatic
https://www.borgbackup.org/
https://wiki.debian.org/msmtp

Setup

First we assume you have some sort of cron entry for borgmatic and also are generating a log file, this would look similar to the below:

0 3 * * * root PATH=$PATH:/usr/local/bin /root/.local/bin/borgmatic -v 2 > /var/log/borgmatic.log 2>&1

This cron entry runs borgmatic at 3 AM nightly and copies the output to a log file at /var/log/borgmatic.log (I have it in /etc/cron.d/borgmatic)
If your log is going to be elsewhere edit the Borgmatic Mailer scripts to reflect the location.

  1. Install msmtp (For Debian: apt-get install msmtp)

  2. Configure your .msmtprc file in /home/username or /root/ (This is your msmtp configuration file), I've included an example for Gmail.

  3. Test ability to send an email with: echo "This is a test message" | msmtp -a default [email protected]

  4. Copy the Borgmatic Mailer scripts to a directory anywhere you'd like and note down the path

  5. Make the scripts executable by cd-ing into the directory you put the scripts and running: chmod +x *

  6. Configure the variables in mailmaker.sh and borg_log_mailer.sh

  7. Edit your borgmatic config.yaml to execute the Borgmatic Mailer main script (These options are under the hooks section, remember to change the paths):
    after_backup:
    - bash /Path/To/borg_log_mailer.sh
    on_error:
    - bash /Path/To/borg_log_mailer.sh

  8. Test run your backup job with: borgmatic -v 2 > /var/log/borgmatic.log 2>&1

About

A set of scripts to notify you via email if your Borgmatic-run Borg backups failed or not

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages