Merge branch 'sparanoid-patch-1' into dev
This commit is contained in:
commit
8c0f58d8f0
2 changed files with 41 additions and 0 deletions
|
|
@ -401,6 +401,24 @@ MAIL="mailx" # default command for Linux mail
|
|||
#MAIL="/path/to/custom/mail_script.py"
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# NOTIFICATIONS
|
||||
# ------------------------------------------------------------------------------
|
||||
#
|
||||
# Third-pary notification services. If no NOTIFICATION_SERVICE provided, no
|
||||
# notifications will be sent.
|
||||
|
||||
# NOTIFICATION_SERVICE="slack"
|
||||
NOTIFICATION_SERVICE=
|
||||
NOTIFICATION_FAILURE_ONLY="yes" # send notifications only if there was an error while creating backup
|
||||
|
||||
# Provider: Slack
|
||||
SLACK_HOOK_URL="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
|
||||
SLACK_CHANNEL="#general"
|
||||
SLACK_USERNAME="duplicity-backup"
|
||||
SLACK_EMOJI="package"
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# TROUBLESHOOTING
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -372,6 +372,15 @@ email_logfile()
|
|||
fi
|
||||
}
|
||||
|
||||
send_notification()
|
||||
{
|
||||
if [ ! -z "$NOTIFICATION_SERVICE" ]; then
|
||||
if [ "$NOTIFICATION_SERVICE" = "slack" ]; then
|
||||
curl -X POST -H 'Content-type: application/json' --data "{\"text\": \"$NOTIFICATION_CONTENT\", \"channel\": \"$SLACK_CHANNEL\", \"username\": \"$SLACK_USERNAME\", \"icon_emoji\": \":$SLACK_EMOJI:\"}" ${SLACK_HOOK_URL}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_lock()
|
||||
{
|
||||
echo "Attempting to acquire lock ${LOCKFILE}" >> ${LOGFILE}
|
||||
|
|
@ -861,6 +870,20 @@ else
|
|||
email_logfile
|
||||
fi
|
||||
|
||||
if [ "$NOTIFICATION_FAILURE_ONLY" = "yes" ]; then
|
||||
if [ ${BACKUP_ERROR} ]; then
|
||||
NOTIFICATION_CONTENT="BACKUP ERROR: ${HOSTNAME} - \`$LOGFILE\`"
|
||||
send_notification
|
||||
fi
|
||||
else
|
||||
if [ ${BACKUP_ERROR} ]; then
|
||||
NOTIFICATION_CONTENT="BACKUP ERROR: ${HOSTNAME} - \`$LOGFILE\`"
|
||||
else
|
||||
NOTIFICATION_CONTENT="BACKUP OK: ${HOSTNAME} - \`$LOGFILE\`"
|
||||
fi
|
||||
send_notification
|
||||
fi
|
||||
|
||||
# remove old logfiles
|
||||
# stops them from piling up infinitely
|
||||
[[ -n "${REMOVE_LOGS_OLDER_THAN}" ]] && find ${LOGDIR} -type f -mtime +"${REMOVE_LOGS_OLDER_THAN}" -delete
|
||||
|
|
|
|||
Loading…
Reference in a new issue