postgres-make-base-backups: and print seconds as times
[mirror/dsa-puppet.git] / modules / postgres / templates / backup_server / postgres-make-base-backups.erb
index 7438bb9..4681527 100755 (executable)
@@ -130,14 +130,14 @@ while read host port username  cluster version; do
                         # get a "randomish" but stable value for this backup run
                         val=$(echo "$MYHOSTNAME-$host-$port-$mtime" | sha256sum | head -c 8)
                         val=$((16#$val))
-                        valmod=$(($val % $DELTA_WAIT_SUCCESS))
-                        after_min=$((delta - MIN_WAIT_SUCCESS))
-                        if [ "$after_min" -gt "$valmod" ]; then
-                            runme=1
-                            log "Planning to run $host:$port $version/$cluster because random computer says so ($after_min > $valmod)."
-                        else
+                        rnd_cuttoff=$(($val % $DELTA_WAIT_SUCCESS))
+                        age_after_min=$((delta - MIN_WAIT_SUCCESS))
+                        if [ "$age_after_min" -lt "$rnd_cuttoff" ]; then
                             runme=0
-                            log "Skipping $host:$port $version/$cluster because random computer says wait ($after_min <= $valmod)."
+                            log "Skipping $host:$port $version/$cluster because random computer says wait ($(format_timedelta "${age_after_min}") < $(format_timedelta "${rnd_cuttoff}") (< $(format_timedelta "${DELTA_WAIT_SUCCESS}"))) + $(format_timedelta "${MIN_WAIT_SUCCESS}")."
+                        else
+                            runme=1
+                            log "Planning to run $host:$port $version/$cluster because random computer says so ($(format_timedelta "${age_after_min}") >= $(format_timedelta "${rnd_cuttoff}"))."
                         fi
                     fi
                 fi