summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Cozic <laurent@pogopixels.com>2013-10-27 14:18:11 +0800
committerLaurent Cozic <laurent@pogopixels.com>2013-10-27 14:18:11 +0800
commit033cabcbcf36f140bc5dd89e228b8de0654045b7 (patch)
tree1d7536be000a1f065b933752787d2fddd6847c46
parenta3cdd8640aae3a75fb26a4ca325c1fc2be361286 (diff)
Fixed support for relative paths
-rw-r--r--rsync_tmbackup.sh17
1 files changed, 13 insertions, 4 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index caa32f9..7339238 100644
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -25,8 +25,11 @@ EXCLUSION_FILE=$3
DEST_MARKER_FILE=$DEST_FOLDER/backup.marker
if [ ! -f "$DEST_MARKER_FILE" ]; then
- echo "Safety check failed - the destination doesn't appear to be a backup folder or drive."
- echo "If it is a backup folder, manually add an empty file name \"$DEST_MARKER_FILE\""
+ echo "Safety check failed - the destination does not appear to be a backup folder or drive (marker file not found)."
+ echo "If it is indeed a backup folder, you may add the marker file by running the following command:"
+ echo ""
+ echo "touch \"$DEST_MARKER_FILE\""
+ echo ""
exit 1
fi
@@ -69,6 +72,9 @@ LINK_DEST_OPTION=""
if [ "$LAST_TIME" == "" ]; then
echo "No previous backup - creating new one."
else
+ # If the path is relative, it needs to be relative to the destination. To keep
+ # it simple, just use an absolute path. See http://serverfault.com/a/210058/118679
+ PREVIOUS_DEST=`cd \`dirname "$PREVIOUS_DEST"\`; pwd`"/"`basename "$PREVIOUS_DEST"`
echo "Previous backup found - doing incremental backup from $PREVIOUS_DEST"
LINK_DEST_OPTION="--link-dest=$PREVIOUS_DEST"
fi
@@ -105,11 +111,14 @@ fi
CMD="$CMD $LINK_DEST_OPTION $SRC_FOLDER/ $DEST/"
CMD="$CMD | grep -E '^deleting|[^/]$'"
+echo "Running command:"
+echo $CMD
+
touch $INPROGRESS_FILE
eval $CMD
EXIT_CODE=$?
-if [ "EXIT_CODE" == "0" ]; then
+if [ "$EXIT_CODE" == "0" ]; then
rm $INPROGRESS_FILE
else
echo "Error: Exited with error code $EXIT_CODE"
-fi \ No newline at end of file
+fi