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.
This commit is contained in:
Laurent Cozic
2013-11-15 17:20:16 +08:00
parent 85fea581a6
commit 2ade9de422
+9 -2
View File
@@ -226,12 +226,19 @@ while [ "1" ]; do
fi fi
if [ "$RSYNC_EXIT_CODE" != "0" ]; then 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" fn_log_error "Exited with error code $RSYNC_EXIT_CODE"
exit $RSYNC_EXIT_CODE exit $RSYNC_EXIT_CODE
fi fi
# -----------------------------------------------------------------------------
# Add symlink to last successful backup
# -----------------------------------------------------------------------------
cd "$DEST_FOLDER"
rm -f -- "latest"
ln -s -- $(basename -- "$DEST") "latest"
cd -
rm -- "$INPROGRESS_FILE" rm -- "$INPROGRESS_FILE"
# TODO: grep for "^rsync error:.*$" in log # TODO: grep for "^rsync error:.*$" in log
fn_log_info "Backup completed without errors." fn_log_info "Backup completed without errors."