netcup-setup/ansible/borg_scripts/check_backup.bash

36 lines
1.1 KiB
Bash

#!/bin/bash
# Configuration
BACKUP_USER="your_remote_user" # Remote SSH username
BACKUP_HOST="your_remote_host" # Remote SSH server
BACKUP_PATH="/path/ro/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 check
if [ "$1" == "--verify-data" ]; then
echo "Starting Borg check with data verification..."
borg check --verify-data $BACKUP_REPO
else
echo "Starting Borg check..."
borg check $BACKUP_REPO
fi
# 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 "Check succeeded (with return code $BORG_EXIT)!"
else
echo "Check failed (with return code $BORG_EXIT)!"
exit 1
fi
# Unset the encryption password for security
unset BORG_PASSPHRASE