Odstraněn cesta k logu
This commit is contained in:
parent
ab8b5ff7d3
commit
1289a2c281
@ -1,22 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Zdrojová složka záloh na HD2
|
# Zdrojová složka záloh na HD2
|
||||||
BACKUP_SRC="/mnt/backup/backup"
|
BACKUP_SRC="/mnt/backup/backup"
|
||||||
# Cílový adresář na Hetzner Storage Boxu
|
# Cílový adresář na Hetzner Storage Boxu
|
||||||
BACKUP_DEST="u409453@u409453.your-storagebox.de:/path/to/backup"
|
BACKUP_DEST="u409453@u409453.your-storagebox.de:/path/to/backup"
|
||||||
# Logovací soubor
|
|
||||||
LOG_FILE="/var/log/backup_transfer.log"
|
|
||||||
# SSH port
|
# SSH port
|
||||||
SSH_PORT=23
|
SSH_PORT=23
|
||||||
|
# E-mailové adresy pro notifikace
|
||||||
# Kontrola existence logovacího souboru a jeho vytvoření, pokud neexistuje
|
EMAIL="tvuj_email@example.com"
|
||||||
if [ ! -f "$LOG_FILE" ]; then
|
SUBJECT="Backup Failure Notification"
|
||||||
touch "$LOG_FILE"
|
|
||||||
chmod 644 "$LOG_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Synchronizace pomocí rsync
|
# Synchronizace pomocí rsync
|
||||||
rsync -avz -e "ssh -p $SSH_PORT" --delete "$BACKUP_SRC" "$BACKUP_DEST"
|
rsync -avz -e "ssh -p $SSH_PORT" --delete "$BACKUP_SRC" "$BACKUP_DEST"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
# Logování
|
echo "Backup failed" | mail -s "$SUBJECT" "$EMAIL"
|
||||||
echo "Backup transfer completed on $(date)" >> "$LOG_FILE"
|
else
|
||||||
|
echo "Backup transfer completed on $(date)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user