diff options
-rwxr-xr-x | backup | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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 |