-
Notifications
You must be signed in to change notification settings - Fork 0
/
user-callback
executable file
·47 lines (37 loc) · 2.04 KB
/
user-callback
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# by marcwa19197. 20-05-2016 ([email protected])
# simple notification script for backintime. (for backintime > version 1.0)
# Place this in your ~/.config/backintime/ directory! Dont forget to chmod +x ;-)
# also see http://backintime.le-web.org/documentation/usercallback/
# config
mail_to="[email protected]"
mail_from="BackInTime <[email protected]>"
# some constants
AKT_DATUM=`date +%d-%m-%Y-%H-%M`
HOSTNAME=`hostname -f`
#
# begin script
#
profile_id="$1"
profile_name="$2"
case "$3" in
#start backup
1) echo -e "Backup started.\nProfileID: $profile_id\nProfileName: $profile_name\nDate: $AKT_DATUM" | mail -s "$HOSTNAME - BackInTime: Backup started" -r "$mail_from" "$mail_to"
;;
2) echo -e "Backup finished.\nProfileID: $profile_id\nProfileName: $profile_name\nDate: $AKT_DATUM" | mail -s "$HOSTNAME - BackInTime: Backup finished" -r "$mail_from" "$mail_to"
;;
3) echo -e "Backup taken\nProfileID: $profile_id\nProfileName: $profile_name\nSnapshotID: $4\nSnapshot Path: $5\nDate: $AKT_DATUM" | mail -s "$HOSTNAME - BackInTime: Backup taken" -r "$mail_from" "$mail_to"
;;
# error!
4) case "$4" in
1) echo -e "Error - no configuration found.\nProfileID: $profile_id\nProfileName: $profile_name\nDate: $AKT_DATUM" | mail -s "$HOSTNAME - BackInTime Error: No config" -r "$mail_from" "$mail_to"
;;
2) echo -e "Error - take snapshot already running.\nProfileID: $profile_id\nProfileName: $profile_name\nDate: $AKT_DATUM" | mail -s "$HOSTNAME - BackInTime Error: Already running backup" -r "$mail_from" "$mail_to"
;;
3) echo -e "Error - cant connect to backup directory\nProfileID: $profile_id\nProfileName: $profile_name\nDate: $AKT_DATUM" | mail -s "$HOSTNAME - BackInTime Error: Backupdirectory not reachable" -r "$mail_from" "$mail_to"
;;
4) echo -e "Error - snapshot already exist\nProfileID: $profile_id\nProfileName: $profile_name\nDate: $AKT_DATUM" | mail -s "$HOSTNAME - BackInTime Error: Snapshot for now already exists" -r "$mail_from" "$mail_to"
;;
esac
;;
esac