summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Cozic <laurent@pogopixels.com>2013-11-15 17:20:16 +0800
committerLaurent Cozic <laurent@pogopixels.com>2013-11-15 17:20:16 +0800
commit2ade9de4229d073102644e59cc9bae27982d6ed0 (patch)
tree02216a401e9733755634e0722fdaa881aad2d9b9
parent85fea581a6f194818d5273d30f68c18ce2aaf474 (diff)
Fixed latest backup symlink issues
Code was in the wrong place (link being added when the backup failed only). Also made the symlink relative to the current folder so that the drive can be mounted with a different path.
-rw-r--r--rsync_tmbackup.sh11
1 files changed, 9 insertions, 2 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index fd997a6..45f8478 100644
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -226,12 +226,19 @@ while [ "1" ]; do
fi
if [ "$RSYNC_EXIT_CODE" != "0" ]; then
- rm -f $DEST_FOLDER/latest
- ln -s $DEST $DEST_FOLDER/latest
fn_log_error "Exited with error code $RSYNC_EXIT_CODE"
exit $RSYNC_EXIT_CODE
fi
+ # -----------------------------------------------------------------------------
+ # Add symlink to last successful backup
+ # -----------------------------------------------------------------------------
+
+ cd "$DEST_FOLDER"
+ rm -f -- "latest"
+ ln -s -- $(basename -- "$DEST") "latest"
+ cd -
+
rm -- "$INPROGRESS_FILE"
# TODO: grep for "^rsync error:.*$" in log
fn_log_info "Backup completed without errors."