#!/bin/sh # Entry point for the `backup` sidecar container. Runs db-backup.sh on a fixed # interval (default: daily). Kept deliberately simple — a sleep loop instead of a # cron daemon — so it works in a bare postgres:16-alpine image. set -eu INTERVAL="${BACKUP_INTERVAL_SECONDS:-86400}" # 86400 = once a day echo "[backup] sidecar started; interval=${INTERVAL}s, keep=${BACKUP_KEEP:-14}, dir=${BACKUP_DIR:-/backups}" # Take one backup shortly after start so a freshly-deployed stack has an # immediate restore point instead of waiting a whole interval. sleep 20 while true; do sh /scripts/db-backup.sh || echo "[backup] run failed; will retry next interval" >&2 sleep "$INTERVAL" done