mirror of
https://github.com/nachoparker/btrfs-snp.git
synced 2024-05-09 07:36:05 +02:00
Add margin for time comparison. (#7)
* Add margin option for time comparison. * Update btrfs-snp * Update btrfs-snp Co-authored-by: nachoparker <nacho@ownyourbits.com>
This commit is contained in:
parent
fa88ea422b
commit
4a3b653342
|
@ -22,6 +22,7 @@ function btrfs-snp()
|
|||
local LIMIT="${3:-0}"
|
||||
local TIME="${4:-0}"
|
||||
local DST="${5:-.snapshots}"
|
||||
local MARGIN=15 # allow for some seconds of inaccuracy for cron / systemd timers
|
||||
|
||||
## usage
|
||||
[[ "$*" == "" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]] && {
|
||||
|
@ -69,7 +70,7 @@ chmod +x /etc/cron.hourly/$BIN"
|
|||
local LATEST=$( sed -r "s|.*_(.*_.*)|\\1|;s|_([0-9]{2})([0-9]{2})([0-9]{2})| \\1:\\2:\\3|" <<< "${SNAPS[-1]}" )
|
||||
LATEST=$( date +%s -d "$LATEST" ) || return 1
|
||||
|
||||
[[ $(( LATEST + TIME )) -gt $( date +%s ) ]] && { echo "No new snapshot needed for $TAG in $DIR"; return 0; }
|
||||
[[ $(( LATEST + TIME )) -gt $(( $( date +%s ) + MARGIN )) ]] && { echo "No new snapshot needed for $TAG in $DIR"; return 0; }
|
||||
}
|
||||
|
||||
## do it
|
||||
|
|
Loading…
Reference in New Issue