Browse Source

setup: pick host-dependent start time

master
Jim Paris 1 month ago
parent
commit
1beda9d613
1 changed files with 9 additions and 3 deletions
  1. +9
    -3
      initial-setup.sh

+ 9
- 3
initial-setup.sh View File

@@ -222,14 +222,20 @@ configure_systemd()

log "Creating systemd files"

# Choose a time between 1am and 6am based on this hostname
HASH=$(echo hash of "$HOSTNAME" | sha1sum)
HOUR=$((0x${HASH:0:8} % 5 + 1))
MINUTE=$((0x${HASH:8:8} % 6 * 10))
TIME=$(printf %02d:%02d:00 $HOUR $MINUTE)

log "Backup time is $TIME"

cat > "$TIMER_UNIT" <<EOF
[Unit]
Description=Borg backup to ${BACKUP_HOST}

[Timer]
OnCalendar=*-*-* 01:00:00
RandomizedDelaySec=1800
FixedRandomDelay=true
OnCalendar=*-*-* $TIME
Persistent=true

[Install]


Loading…
Cancel
Save