borg_prune.sh 427 B

12345678910111213141516
  1. #!/bin/bash
  2. # Load environment variables from .env file
  3. source .env
  4. # Export Borg passphrase
  5. export BORG_PASSPHRASE=$PASSPHRASE
  6. export BORG_RSH="ssh -i $SSH_KEY -p $SSH_PORT"
  7. # Prune old backups
  8. 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"
  9. if [ $? -ne 0 ]; then
  10. echo "Borg prune failed."
  11. exit 1
  12. fi