#!/usr/bin/env bash # offsync/start.sh # run the offsite backup MYDIR=$(dirname $0) source "${MYDIR}/config" if -z "${RSYNC_TARGET}"; then echo "Check your configuration!" 2>&1 exit 1 fi date >> "${LOGFILE}" /usr/local/bin/rsync -auvhNHXxrz\ --stats --protect-args --fileflags --force-change --delete\ --files-from="$MYDIR/offsync.include" --no-relative\ / "${RSYNC_TARGET}" >> "$LOGFILE" 2>&1 & echo $! > "$PIDFILE" # wait for rsync to finish wait $(cat "$PIDFILE") rm "$PIDFILE" tail "$LOGFILE" | mail -E -s "Offsite backup of $(hostname) completed" $MAILTO