#!/bin/bash # Configuration BACKUP_USER="your_remote_user" # Remote SSH username BACKUP_HOST="your_remote_host" # Remote SSH server BACKUP_PATH="/path/to/remote/backup/folder" # Remote backup folder BORG_PASSPHRASE="your_encryption_password" # Encryption password (in plain text) BACKUP_NAME="backup-$(date +'%Y-%m-%d')" # Name of the backup archive BACKUP_REPO="ssh://$BACKUP_USER@$BACKUP_HOST/$BACKUP_PATH" # Borg repository location # Environment variable for Borg encryption export BORG_PASSPHRASE # Run Borg backup echo "Starting Borg backup..." borg create --verbose --filter AME --list --stats --compression lz4 \ $BACKUP_REPO::$BACKUP_NAME \ /etc \ /var/vol # Capture Borg exit status BORG_EXIT=$? # Check if the backup succeeded or was partially successful (exit code 0 or 1) if [ $BORG_EXIT -eq 0 ] || [ $BORG_EXIT -eq 1 ]; then echo "Backup succeeded (with return code $BORG_EXIT)!" else echo "Backup failed (with return code $BORG_EXIT)!" exit 1 fi # Prune old backups (keep last 7 daily, 4 weekly, and 6 monthly backups) borg prune --list $BACKUP_REPO --keep-daily=7 --keep-weekly=4 --keep-monthly=6 # Unset the encryption password for security unset BORG_PASSPHRASE