#!/bin/sh # Backup-Sidecar Entrypoint # ========================== # Image-unabhaengiger Shell-Scheduler (kein cron noetig): laeuft im Vordergrund und # stoesst backup.sh einmal taeglich zur konfigurierten Stunde an. Funktioniert auf # Debian (postgres:18, GNU date) wie auf Alpine — der fruehere crond-Ansatz brauchte # /etc/crontabs (Alpine-only) und crashte im Debian-Image. set -e BACKUP_HOUR="${BACKUP_HOUR:-3}" # Stunde (0-23) fuer das taegliche Backup HHMM=$(printf '%02d:00' "$BACKUP_HOUR") echo "[$(date)] Backup-Sidecar gestartet (Shell-Scheduler, taeglich $HHMM)." echo "[$(date)] Backup-Verzeichnis: /backups Fotos: /data/photos" while :; do now=$(date +%s) target=$(date -d "$HHMM" +%s 2>/dev/null || echo "") if [ -z "$target" ]; then # Fallback ohne GNU 'date -d': einfach 24h schlafen. sleep 86400 else [ "$target" -le "$now" ] && target=$(date -d "$HHMM tomorrow" +%s) sleep "$((target - now))" fi echo "[$(date)] Starte Backup ..." /bin/sh /scripts/backup.sh >> /backups/backup.log 2>&1 || echo "[$(date)] WARNUNG: backup.sh Exit $?" done