hub-db-backup: parse the snapshot time in a form BusyBox date reads (CI red since ab2b304: 9/15 on the Alpine runner)
gates / gates (push) Successful in 1m46s
gates / gates (push) Successful in 1m46s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
@@ -29,8 +29,9 @@ SNAP=$(kubectl -n felhom-system exec deploy/hub -- sh -c 'ls -1 /data/snapshots/
|
||||
NAME=${SNAP##*/}
|
||||
STAMP=${NAME#hub-}; STAMP=${STAMP%.db} # 20261005T020000Z
|
||||
case "$STAMP" in [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9]Z) ;; *) die "unexpected snapshot name $NAME" ;; esac
|
||||
ISO=$(echo "$STAMP" | sed -E 's/^(....)(..)(..)T(..)(..)(..)Z$/\1-\2-\3T\4:\5:\6Z/')
|
||||
SNAP_EPOCH=$(date -u -d "$ISO" +%s) || die "cannot parse snapshot time $ISO"
|
||||
# "YYYY-MM-DD hh:mm:ss" with -u: the one form both GNU date and BusyBox date (the CI runner, Alpine) read.
|
||||
WHEN=$(echo "$STAMP" | sed -E 's/^(....)(..)(..)T(..)(..)(..)Z$/\1-\2-\3 \4:\5:\6/')
|
||||
SNAP_EPOCH=$(date -u -d "$WHEN" +%s) || die "cannot parse snapshot time $WHEN (UTC)"
|
||||
AGE=$((NOW - SNAP_EPOCH))
|
||||
[ "$AGE" -le $((MAX_AGE_H * 3600)) ] || die "newest snapshot $NAME is $((AGE / 3600)) h old (limit ${MAX_AGE_H} h) — the hub stopped snapshotting"
|
||||
log "snapshot $NAME, $((AGE / 60)) min old"
|
||||
|
||||
Reference in New Issue
Block a user