From 474013f24c917a85af5c15ad54ae4e9b19e70a26 Mon Sep 17 00:00:00 2001 From: MNTLe Date: Tue, 4 Oct 2022 01:14:03 +1300 Subject: [PATCH] rsync_backup.sh Initial commit --- rsync_backup.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 rsync_backup.sh diff --git a/rsync_backup.sh b/rsync_backup.sh new file mode 100644 index 0000000..fa202d2 --- /dev/null +++ b/rsync_backup.sh @@ -0,0 +1,37 @@ +#!/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" \ No newline at end of file