mirror of
https://github.com/laurent22/rsync-time-backup
synced 2024-11-10 14:14:16 +00:00
More elegant cross-platform date logic.
This commit is contained in:
parent
9b9a564447
commit
f011e1a7ab
1 changed files with 7 additions and 12 deletions
|
@ -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
|
||||
# -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue