local backup_month=
local now_month=
local diff=
- [ "$date" == none ] || return 1
+ [ "$date" == "none" ] && return 1
backup_month=$(date --date="$date" '+%Y-%m')
now_month=$(date '+%Y-%m')
diff=$(( ($(date --date="$date" +%s) - $(date +%s)) / 86400 ))
local LIGHTGREEN="\e[1;32m"
local RESET="\e[0m"
local color="$LIGHTGREEN"
+
local stat=
local type=
+ local status=
local line=1
local stat_file=
stat_file=$(echo "$config" | jq --raw-output '.backup_stat_file')
[ -f "$stat_file" ] || printf "none%-.s\n" {1..3} > "$stat_file"
for type in day week month; do
+ status="ok"
stat=$(awk "NR==$line {print; exit}" "$stat_file")
- is_backup_old "$type" "$stat" || color="$LIGHTRED"
- printf "${color}%s %s${RESET}\n" "$type" "$stat"
+ is_backup_old "$type" "$stat" || status="old"
+ [ "$status" != "ok" ] || color="$LIGHTRED"
+
+ printf "${color}%-5s %-10s %s${RESET}\n" "$type" "$stat" "$status"
((line++))
done
}
assert_success
[ -f "build/test/stats" ]
- assert_line --index 0 "day none"
- assert_line --index 1 "week none"
- assert_line --index 2 "month none"
+ assert_line --index 0 "day none old"
+ assert_line --index 1 "week none old"
+ assert_line --index 2 "month none old"
}
\ No newline at end of file