#!/bin/sh set -eu [ -f /etc/backup.env ] && . /etc/backup.env NTFY_URL="${NTFY_URL:-https://ntfy.ginnoir.com/backup}" NTFY_TITLE="${NTFY_TITLE:-ValhallaBackup}" KOPIA_PASSWORD="${KOPIA_REPOSITORY_PASSWORD:-${KOPIA_PASSWORD:-}}" notify() { priority="$1" message="$2" curl -sf -H "Title: ${NTFY_TITLE}" -H "Priority: ${priority}" -d "${message}" "${NTFY_URL}" >/dev/null 2>&1 || true } if [ -z "${KOPIA_PASSWORD}" ]; then notify high "KOPIA_REPOSITORY_PASSWORD not set — snapshots skipped" exit 1 fi if ! docker ps --format '{{.Names}}' | grep -qx kopia; then notify high "Kopia container not running — snapshots skipped" exit 1 fi FAILED=0 while IFS= read -r path || [ -n "${path}" ]; do case "${path}" in ''|\#*) continue ;; esac if ! docker exec -e KOPIA_PASSWORD="${KOPIA_PASSWORD}" kopia kopia snapshot create "${path}"; then FAILED=1 fi done < /snapshot-paths.txt if [ "${FAILED}" -eq 0 ]; then notify default "Snapshots OK ($(date +%Y-%m-%d\ %H:%M))" else notify high "One or more snapshots FAILED — check docker logs kopia" exit 1 fi