From 07d357490e554e8af786c3d4d0cb2b74d7793d1d Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Wed, 4 Apr 2018 21:23:03 +0200 Subject: Fixed issue with log file, apparently rsync doesn't like it being in quotes --- backup | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/backup b/backup index c985399..42bbdbf 100755 --- a/backup +++ b/backup @@ -5,7 +5,7 @@ LOG_DIR="$HOME/rsync_logs" LOG_FILE="$LOG_DIR/$(date --iso-8601).log" -RSYNC_OPTS="-aP --no-owner --delete-during --exclude='lost+found' --log-file='$LOG_FILE'" +RSYNC_OPTS=("-aP" "--no-owner" "--delete-during" "--exclude=\"lost+found\"" "--log-file=$LOG_FILE") if [ $# -lt 2 ]; then echo "Usage: backup " @@ -32,4 +32,11 @@ if [ ! -d "$LOG_DIR" ]; then fi fi -rsync $RSYNC_OPTS "${1%/}/*" "$2" +echo "$(date)" > "$LOG_FILE" +if [ $? -ne 0 ]; then + echo "Failed to create log file, exiting" + exit 1 +fi + +echo "rsync $RSYNC_OPTS ${1%/}/* $2" >> "$LOG_FILE" +rsync $RSYNC_OPTS ${1%/}/* $2 -- cgit v1.2.3