#!/bin/bash REPO_SERVER_SSH="spacedock-backups" REPO_SERVER_HOSTNAME="spacedock.servers.ezri.dev" export BORG_REPO=ssh://${REPO_SERVER_SSH}/~/$(&2; exit 2' INT TERM # Ensure we can connect to the remote host while true; do ping -c 1 -W 1 ${REPO_SERVER_HOSTNAME} > /dev/null if [ $? -eq 0 ]; then break fi echo "Could not connect to ${REPO_SERVER_HOSTNAME}, retrying in 5 seconds..." sleep 5 done echo "Starting backup..." borg create \ --verbose \ --filter AME \ --list \ --stats \ --show-rc \ --compression lz4 \ --sparse \ --one-file-system \ --exclude-caches \ --exclude-from /home/ezri/.borgignore \ ::'{now}' \ "${backup_dirs[@]}" backup_exit=$? echo "Backup complete, pruning repository..." borg prune \ --verbose \ --list \ --show-rc \ --keep-hourly 48 \ --keep-daily 12 \ --keep-weekly 6 \ --keep-monthly 10 prune_exit=$? echo "Prune complete, compacting repository..." borg compact compact_exit=$? global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit )) global_exit=$(( compact_exit > global_exit ? compact_exit : global_exit )) exit ${global_exit}