#!/bin/bash set -euo pipefail export BORG_PASSPHRASE=$(cat /root/.borg-passphrase) REPO="{{ borg_repo }}" LOGFILE="{{ borg_logfile }}" echo "[$(date)] Starte Backup: {{ inventory_hostname }}" >> "$LOGFILE" borg create \ --verbose \ --filter AME \ --remote-path={{ borg_remote_path }} \ --stats \ --show-rc \ --compression {{ borg_compression }} \ "${REPO}::{{ inventory_hostname }}-$(date +%Y-%m-%d_%H-%M)" \ {{ backup_source }} >> "$LOGFILE" 2>&1 BACKUP_RC=$? borg prune -v --list "${REPO}" \ --keep-daily={{ borg_retention_daily }} \ --keep-weekly={{ borg_retention_weekly }} \ --keep-monthly={{ borg_retention_monthly }} >> "$LOGFILE" 2>&1 PRUNE_RC=$? borg compact "${REPO}" >> "$LOGFILE" 2>&1 GLOBAL_RC=$(( BACKUP_RC > PRUNE_RC ? BACKUP_RC : PRUNE_RC )) echo "[$(date)] Backup beendet mit Code $GLOBAL_RC" >> "$LOGFILE" exit $GLOBAL_RC