aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xstart.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/start.sh b/start.sh
index 351474b..e6abfa3 100755
--- a/start.sh
+++ b/start.sh
@@ -10,6 +10,11 @@ if -z "${RSYNC_TARGET}"; then
exit 1
fi
+if [[ -e "$PIDFILE" ]]; then
+ echo "Offsync already running, exiting" 2>&1
+ exit 1
+fi
+
date >> "${LOGFILE}"
/usr/local/bin/rsync -auvhNHXxrz\
--stats --protect-args --fileflags --force-change --delete\
@@ -20,6 +25,10 @@ echo $! > "$PIDFILE"
# wait for rsync to finish
wait $(cat "$PIDFILE")
-rm "$PIDFILE"
+
+# stop may have already deleted it
+if [[ -e "$PIDFILE" ]]; then
+ rm "$PIDFILE"
+fi
tail "$LOGFILE" | mail -E -s "Offsite backup of $(hostname) completed" $MAILTO