#!/bin/bash # Load environment variables from .env file source .env # Export Borg passphrase export BORG_PASSPHRASE=$PASSPHRASE export BORG_RSH="ssh -i $SSH_KEY -p $SSH_PORT" # Prune old backups sudo -E borg prune --verbose --glob-archives '{hostname}-*' --keep-daily=7 --keep-weekly=4 --keep-monthly=6 --keep-yearly=10 "$SERVER_USER@$SERVER_IP:$REPOSITORY" if [ $? -ne 0 ]; then echo "Borg prune failed." exit 1 fi