automation-scripts/scripts/8_backup_to_hetzner.sh

21 lines
552 B
Bash
Raw Normal View History

2024-07-05 05:32:17 +00:00
#!/bin/bash
2024-07-07 05:41:46 +00:00
2024-07-05 05:32:17 +00:00
# Zdrojová složka záloh na HD2
BACKUP_SRC="/mnt/backup/backup"
# Cílový adresář na Hetzner Storage Boxu
BACKUP_DEST="u409453@u409453.your-storagebox.de:/path/to/backup"
# SSH port
SSH_PORT=23
2024-07-07 05:41:46 +00:00
# E-mailové adresy pro notifikace
EMAIL="tvuj_email@example.com"
SUBJECT="Backup Failure Notification"
2024-07-05 05:32:17 +00:00
# Synchronizace pomocí rsync
rsync -avz -e "ssh -p $SSH_PORT" --delete "$BACKUP_SRC" "$BACKUP_DEST"
2024-07-07 05:41:46 +00:00
if [ $? -ne 0 ]; then
echo "Backup failed" | mail -s "$SUBJECT" "$EMAIL"
else
echo "Backup transfer completed on $(date)"
fi