From c046c4dd4243652316888a8bd72060bf3ee2c267 Mon Sep 17 00:00:00 2001 From: nils biesalski Date: Thu, 31 Oct 2013 13:51:08 +0100 Subject: [PATCH] Changed regex for grep iirc POSIX mode http://stackoverflow.com/questions/6901171/is-d-not-supported-by-greps-basic-expressions --- rsync_tmbackup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index bb961c2..2f078d1 100644 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -36,10 +36,10 @@ fi # ----------------------------------------------------------------------------- # Setup additional variables # ----------------------------------------------------------------------------- - +BACKUP_REGEX="^[[:digit:]][[:digit:]][[:digit:]][[:digit:]]-[[:digit:]][[:digit:]]-[[:digit:]][[:digit:]]-[[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]$" NOW=$(date +"%Y-%m-%d-%H%M%S") DEST=$DEST_FOLDER/$NOW -LAST_TIME=$(ls -1 $DEST_FOLDER | grep "\d\d\d\d-\d\d-\d\d-\d\d\d\d\d\d" | tail -n 1) +LAST_TIME=$(ls -1 $DEST_FOLDER | grep "$BACKUP_REGEX" | tail -n 1) PREVIOUS_DEST=$DEST_FOLDER/$LAST_TIME INPROGRESS_FILE=$DEST_FOLDER/backup.inprogress @@ -52,10 +52,10 @@ if [ -f "$INPROGRESS_FILE" ]; then # - Last backup is moved to current backup folder so that it can be resumed. # - 2nd to last backup becomes last backup. echo "$INPROGRESS_FILE already exists - the previous backup failed or was interrupted. Backup will resume from there." - LINE_COUNT=$(ls -1 $DEST_FOLDER | grep "\d\d\d\d-\d\d-\d\d-\d\d\d\d\d\d" | tail -n 2 | wc -l) + LINE_COUNT=$(ls -1 $DEST_FOLDER | grep "$BACKUP_REGEX" | tail -n 2 | wc -l) mv $PREVIOUS_DEST $DEST if [ "$LINE_COUNT" -gt 1 ]; then - SECOND_LAST_TIME=$(ls -1 $DEST_FOLDER | grep "\d\d\d\d-\d\d-\d\d-\d\d\d\d\d\d" | tail -n 2 | head -n 1) + SECOND_LAST_TIME=$(ls -1 $DEST_FOLDER | grep "$BACKUP_REGEX" | tail -n 2 | head -n 1) LAST_TIME=$SECOND_LAST_TIME else LAST_TIME=""