backup-container/src/schedule.sh
Andras Schmelczer 88aed211de
All checks were successful
ShellCheck / shellcheck (push) Successful in 5s
Docker / build (push) Successful in 18s
Handle nested subvolumes & remove broken git exclusion
2026-09-27 14:58:14 +01:00

24 lines
779 B
Shell
Executable file

#!/bin/bash
# Preserve the wrapper's failure through the logging pipeline and stop the loop.
set -eo pipefail
log_message() {
stdbuf -o0 tee -a "$(get_log_file_name)"
}
get_log_file_name() {
echo "/backup-logs/backup_$(date +%Y)_week_$(date +%U).log"
}
echo "Starting schedule script at $(date)" | log_message
mkdir -p /health || exit 1
trap 'rm -f /health/container_start_time.log.$$' EXIT
date -u '+%Y-%m-%dT%H:%M:%SZ' > /health/container_start_time.log.$$ &&
mv -fT /health/container_start_time.log.$$ /health/container_start_time.log || exit 1
while true; do
# The wrapper checks every repository after backups, then sleeps for any
# unused part of SLEEP_TIME before allowing the next backup round.
/src/backup-wrapper.sh 2>&1 | log_message
done