#!/bin/bash

set -euo pipefail

source /etc/restic/edge01.env

exec 9>/run/restic-edge01.lock

if ! flock -n 9; then
    echo "Another Restic operation is already running."
    exit 1
fi

echo "Starting edge01 backup at $(date --iso-8601=seconds)"

restic backup \
    /etc \
    /home/debian \
    /opt \
    --exclude /opt/backups \
    --exclude '/opt/docker/gitea/data/git/repositories/*/*.git/tmp' \
    --tag edge01 \
    --tag automatic

echo "Backup completed at $(date --iso-8601=seconds)"
