diff options
| author | Robert Bruce Park <r@robru.ca> | 2013-11-15 11:08:28 -0800 |
|---|---|---|
| committer | Robert Bruce Park <r@robru.ca> | 2013-11-15 11:08:28 -0800 |
| commit | f011e1a7ab0f2dc4fc6de85b7a62e65d6f80fa4b (patch) | |
| tree | 748e8ec93e9ad7ca08976c6c547a967c7fd5f64e | |
| parent | 9b9a564447cc6bf1aa99b65e57c3ecafefe9aca4 (diff) | |
More elegant cross-platform date logic.
| -rw-r--r-- | rsync_tmbackup.sh | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index 10ec4f7..3aa0712 100644 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -97,25 +97,20 @@ fi # Setup additional variables # ----------------------------------------------------------------------------- -export IFS=$'\n' # Better for handling spaces in filenames. +# Date logic NOW=$(date +"%Y-%m-%d-%H%M%S") +EPOCH=$(date "+%s") +KEEP_ALL_DATE=$(($EPOCH - 86400)) # 1 day ago +KEEP_DAILIES_DATE=$(($EPOCH - 2678400)) # 31 days ago + + +export IFS=$'\n' # Better for handling spaces in filenames. PROFILE_FOLDER="$HOME/.rsync_tmbackup" LOG_FILE="$PROFILE_FOLDER/$NOW.log" DEST=$DEST_FOLDER/$NOW PREVIOUS_DEST=$(fn_find_backups | sort | tail -n 1) INPROGRESS_FILE=$DEST_FOLDER/backup.inprogress -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 # ----------------------------------------------------------------------------- |
