From bda24be00314f7146bc5064193497f640004faa4 Mon Sep 17 00:00:00 2001 From: David Arthur Date: Wed, 13 Nov 2013 13:29:08 -0500 Subject: [PATCH 1/3] Add a "latest" symlink when backup is successful --- rsync_tmbackup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index 754189f..ea5fb8f 100644 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -226,6 +226,7 @@ while [ "1" ]; do fi if [ "$RSYNC_EXIT_CODE" != "0" ]; then + ln -s $DEST $DEST/../latest fn_log_error "Exited with error code $RSYNC_EXIT_CODE" exit $RSYNC_EXIT_CODE fi From 0c679903afba716726bbf3040f697622985d653b Mon Sep 17 00:00:00 2001 From: David Arthur Date: Wed, 13 Nov 2013 15:52:24 -0500 Subject: [PATCH 2/3] Fixed Brain fart --- rsync_tmbackup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index ea5fb8f..fd997a6 100644 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -226,7 +226,8 @@ while [ "1" ]; do fi if [ "$RSYNC_EXIT_CODE" != "0" ]; then - ln -s $DEST $DEST/../latest + 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 From 2ade9de4229d073102644e59cc9bae27982d6ed0 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 15 Nov 2013 17:20:16 +0800 Subject: [PATCH 3/3] 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. --- rsync_tmbackup.sh | 11 +++++++++-- 1 file 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."