diff options
| author | Manuel Molina Cuberos <manuelmc@ronmiel2.local> | 2017-12-08 22:20:53 +0100 |
|---|---|---|
| committer | Manuel Molina Cuberos <manuelmc@ronmiel2.local> | 2017-12-08 22:20:53 +0100 |
| commit | 31a7bac4b4520deb747c429df0ab3e73f19c1816 (patch) | |
| tree | efe4821ec7c79aac66af43cf33ee9b5d69461366 /rsync_tmbackup.sh | |
| parent | d13af58252b52cb6825799de14dd264810ad82a8 (diff) | |
Replaced operator '=~' with 'grep -Eq' and using a perl one-liner to avoid 'date -j'. Both are not compatible with Mac OS X Tiger.
Diffstat (limited to 'rsync_tmbackup.sh')
| -rwxr-xr-x | rsync_tmbackup.sh | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index 104ee66..1bdd7cb 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -54,6 +54,14 @@ fn_parse_date() { case "$OSTYPE" in linux*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; cygwin*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; + darwin8.0) yy=`expr ${1:0:4}` + mm=`expr ${1:5:2} - 1` + dd=`expr ${1:8:2}` + hh=`expr ${1:11:2}` + mi=`expr ${1:13:2}` + ss=`expr ${1:15:2}` + # Because under MacOS X Tiger 'date -j' doesn't work, we do this: + perl -e 'use Time::Local; print timelocal('$ss','$mi','$hh','$dd','$mm','$yy'),"\n";' ;; darwin*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;; FreeBSD*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;; esac @@ -76,14 +84,15 @@ fn_expire_backup() { } fn_parse_ssh() { - if [[ "$DEST_FOLDER" =~ ^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$ ]] + # To keep compatibility with bash version < 3, we use grep + if echo "$DEST_FOLDER"|grep -Eq '^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$' then SSH_USER=$(echo "$DEST_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\1/') SSH_HOST=$(echo "$DEST_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\2/') SSH_DEST_FOLDER=$(echo "$DEST_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\3/') SSH_CMD="ssh -p $SSH_PORT ${SSH_USER}@${SSH_HOST}" SSH_DEST_FOLDER_PREFIX="${SSH_USER}@${SSH_HOST}:" - elif [[ "$SRC_FOLDER" =~ ^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$ ]] + elif echo "$SRC_FOLDER"|grep -Eq '^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$' then SSH_USER=$(echo "$SRC_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\1/') SSH_HOST=$(echo "$SRC_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\2/') |
