rsync_backup_gotify/rsync_backup.sh

37 lines
846 B
Bash
Raw Normal View History

2022-10-04 01:14:03 +13:00
#!/bin/bash
# Specifications
SOURCES=("[SOURCE1] [SOURCE2]")
TARGET="[DESTINATION]"
GOTIFY_SERVER="[SERVERURL]"
GOTIFY_TOKEN="[TOKEN]"
LOGFILE="rsync.log"
rm $LOGFILE
# Perform the backup using rsync
rsync -av --exclude '@eaDir' \
--no-perms \
--no-group \
--no-owner \
--inplace \
--exclude=[#]recycle \
--log-file=$LOGFILE \
--log-file-format="File changed! %f %i" \
$SOURCES $TARGET
RESULT=$?
if [[ $RESULT -gt 0 ]]
then
SUBJECT="ERROR - Rsync Report"
PRIORITY="10"
else
SUBJECT="SUCCESS - Rsync Report"
PRIORITY="1"
fi
# Send the notification
INTRO=$'The last three lines of the log are as follows:\n'
MESSAGE="$(tail -n 3 $LOGFILE)"
curl "$GOTIFY_SERVER/message?token=$GOTIFY_TOKEN" -F "title=$SUBJECT" -F "message=$INTRO $MESSAGE" -F "priority=$PRIORITY"