14 lines
451 B
Bash
Executable File
14 lines
451 B
Bash
Executable File
#!/bin/sh
|
|
# Runs backup.sh every day at BACKUP_HOUR:00 (in TZ, default UTC).
|
|
set -eu
|
|
|
|
hour="${BACKUP_HOUR:-3}"
|
|
echo "backup: daily at ${hour}:00 ${TZ:-UTC}, keeping ${BACKUP_KEEP_DAYS:-14} days, into /backups"
|
|
while true; do
|
|
now="$(date +%s)"
|
|
next="$(date -d "today ${hour}:00" +%s)"
|
|
if [ "$next" -le "$now" ]; then next="$(date -d "tomorrow ${hour}:00" +%s)"; fi
|
|
sleep "$((next - now))"
|
|
/scripts/backup.sh || echo "backup: FAILED" >&2
|
|
done
|