#!/bin/sh # Startup wrapper: restore backup if needed, start periodic backup loop, then start Open WebUI. set -eu # 1. Restore if db doesn't exist /restore.sh # 2. Start background backup loop: hourly rolling snapshot (overwritten each run) # plus one dated snapshot per day, keeping the newest OWUI_BACKUP_DAILY_KEEP # (default 7) days. ( BACKUP_INTERVAL="${BACKUP_INTERVAL_SECONDS:-3600}" echo "[start] Backup loop started — interval: \${BACKUP_INTERVAL}s" while true; do sleep "$BACKUP_INTERVAL" /backup.sh done ) & # 3. Run initial backup after 60s (so the db exists after open-webui starts) ( sleep 60 /backup.sh ) & # 4. Start Open WebUI (exec so it becomes PID 1) exec ./start.sh