aboutsummaryrefslogtreecommitdiffstats
path: root/backup
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2018-04-04 21:23:03 +0200
committerEduardo Pedroni <e.pedroni91@gmail.com>2018-04-04 21:23:03 +0200
commit07d357490e554e8af786c3d4d0cb2b74d7793d1d (patch)
tree547e371194019ba9dc6aa2bc5d9498a0ae2f429b /backup
parente5a8226936512f4a7c5c5bac5676431b97334d78 (diff)
Fixed issue with log file, apparently rsync doesn't like it being in quotes
Diffstat (limited to 'backup')
-rwxr-xr-xbackup11
1 files 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 <src> <dst>"
@@ -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