#!/usr/bin/env bash set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" service=/etc/systemd/system/homelab-oci-backup.service timer=/etc/systemd/system/homelab-oci-backup.timer fresh_service=/etc/systemd/system/homelab-oci-backup-freshness.service fresh_timer=/etc/systemd/system/homelab-oci-backup-freshness.timer service_user="$(id -un)" if [[ "$(id -u)" == 0 ]]; then echo 'Run this command as the Debian operator, not root, so the timers use the correct OCI credentials and state.' >&2 exit 1 fi sudo tee "${service}" >/dev/null </dev/null <<'EOF' [Unit] Description=Daily encrypted Jeannie OCI backup upload [Timer] OnCalendar=*-*-* 03:15:00 Persistent=true RandomizedDelaySec=15m [Install] WantedBy=timers.target EOF sudo tee "${fresh_service}" >/dev/null </dev/null <<'EOF' [Unit] Description=Daily OCI backup freshness check [Timer] OnCalendar=*-*-* 04:00:00 Persistent=true [Install] WantedBy=timers.target EOF sudo systemctl daemon-reload sudo systemctl enable --now homelab-oci-backup.timer sudo systemctl enable --now homelab-oci-backup-freshness.timer echo "OCI backup timer enabled: daily at 03:15 with up to 15 minutes jitter." echo "OCI backup freshness timer enabled: daily at 04:00 (36-hour default threshold)."