Add MacOSX compatibility.

This commit is contained in:
Robert Bruce Park
2013-11-15 10:24:52 -08:00
parent 324a3ffc9a
commit ae7998025a
+15 -4
View File
@@ -33,7 +33,10 @@ trap 'fn_terminate_script' SIGINT
fn_parse_date() { fn_parse_date() {
# Converts YYYY-MM-DD-HHMMSS to YYYY-MM-DD HH:MM:SS and then to Unix Epoch. # Converts YYYY-MM-DD-HHMMSS to YYYY-MM-DD HH:MM:SS and then to Unix Epoch.
date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s case "$OSTYPE" in
linux*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;;
darwin*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;;
esac
} }
fn_find_backups() { fn_find_backups() {
@@ -101,8 +104,17 @@ LOG_FILE="$PROFILE_FOLDER/$NOW.log"
DEST=$DEST_FOLDER/$NOW DEST=$DEST_FOLDER/$NOW
PREVIOUS_DEST=$(fn_find_backups | sort | tail -n 1) PREVIOUS_DEST=$(fn_find_backups | sort | tail -n 1)
INPROGRESS_FILE=$DEST_FOLDER/backup.inprogress INPROGRESS_FILE=$DEST_FOLDER/backup.inprogress
KEEP_ALL_DATE=$(date -d '-1 day' +%s)
KEEP_DAILIES_DATE=$(date -d '-1 month' +%s) case "$OSTYPE" in
linux*)
KEEP_ALL_DATE=$(date -d '-1 day' +%s)
KEEP_DAILIES_DATE=$(date -d '-1 month' +%s)
;;
darwin*)
KEEP_ALL_DATE=$(date -j -f "%a %b %d %T %Z %Y" "`date -v -1d`" "+%s")
KEEP_DAILIES_DATE=$(date -j -f "%a %b %d %T %Z %Y" "`date -v -1m`" "+%s")
;;
esac
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Create profile folder if it doesn't exist # Create profile folder if it doesn't exist
@@ -188,7 +200,6 @@ while [ "1" ]; do
prev=$date prev=$date
done done
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Start backup # Start backup
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------