Backintime Email Notification

A lot of articles about this (there aren’t many to begin with) are out of date since the arguments passed to user-callback by backintime have changed recently.

Install mailutils package using sudo apt install mailutils

Create ~/.config/backintime/user-callback and add the following (years ago this file was called user.callback rather than user-callback):

Bash
#!/bin/sh

email="user@localhost"
profile_id=$1
profile_name=$2
reason=$3
error=$4

case "$reason" in
1) echo "Backup starting" | mail -s "Backup Starting" ${email}
;;
2) echo "Backup finishing" | mail -s "Backup Finishing" ${email}
;;
3) echo "Backup completed for profile ${profile_id}: ${profile_name}" | mail -s "Backup Completed for ${profile_id}: ${profile_name}" ${email}
;;
4) msg="An error occurred during backup for profile ${profile_id}: ${profile_name} The error was:"
case "$error" in
1) msg="${msg} Application not configured";;
2) msg="${msg} Process already running";;
3) msg="${msg} Can't find snapshots folder";;
4) msg="${msg} A snapshot for 'now' already exists";;
esac
echo "${msg}" | mail -s "Backintime Error" ${email}
;;
5) echo "Application starting" | mail -s "Backintime Starting" ${email}
;;
6) echo "Application closing" | mail -s "Backintime Closing" ${email}
;;
7) echo "Mounting all necessary drives" | mail -s "Backintime Mounted Drives" ${email}
;;
8) echo "Unmount all drives" | mail -s "Backintime Unmounted Drives" ${email}
;;
esac

Change user@localhost to your email address.

Make it executable by running chmod u+x ~/.config/backintime/user-callback

You might think you need to untick Settings; Expert Options; Redirect stdout to /dev/null in cronjobs – you don’t.

That should be it. Run a test backup from the GUI and you should get some emails sent to you. It’ll also work from a cron job if you’ve set backintime to run on a schedule.

Some useful references as background and if you want to do things slightly differently: