updating backup.sh
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 2s

This commit is contained in:
2025-08-16 22:35:10 -03:00
parent a32bcb34a3
commit 5f77376a46

View File

@@ -6,10 +6,6 @@ SERVER_FILE="https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/backup.
SERVER_OK=1
HOSTNAME=$(cat /etc/hostname)
# Check if the server file exists
curl -s --head $SERVER_FILE | head -n 1 | grep -E "HTTP/[12] [23].." > /dev/null
if [ $? -ne 0 ]; then
NOTIFY_URL="http://notify.haven"
# Function to send notification
@@ -20,6 +16,11 @@ send_notify() {
-H "Content-Type: application/json" \
-d "{\"title\": \"$title\", \"message\": \"$message\"}"
}
# Check if the server file exists
curl -s --head $SERVER_FILE | head -n 1 | grep -E "HTTP/[12] [23].." > /dev/null
if [ $? -ne 0 ]; then
echo "Error: $SERVER_FILE not found." >&2
send_notify "[Docker Backup][$HOSTNAME] Error" "❌ <span style='color:red'>Server file not found:</span> $SERVER_FILE"
SERVER_OK=0
@@ -57,9 +58,6 @@ REMOTE_USER="ivanch"
REMOTE_HOST="nas.haven"
REMOTE_DIR="/export/Backup/Docker/$(cat /etc/hostname)"
# Create a compressed backup file
zip -r $BACKUP_FILE $SOURCE_DIR
# Create a compressed backup file
if ! zip -r $BACKUP_FILE $SOURCE_DIR; then
send_notify "Backup Error" "❌ <span style='color:red'>Failed to create backup archive for:</span> $SOURCE_DIR"