diff --git a/backup.sh b/backup.sh
index a824a86..9204f64 100644
--- a/backup.sh
+++ b/backup.sh
@@ -14,7 +14,7 @@ send_notify() {
local message="$2"
curl -s -X POST "$NOTIFY_URL" \
-H "Content-Type: application/json" \
- -d "{\"title\": \"$title\", \"message\": \"$message\"}"
+ -d "{\"title\": \"Docker Backup - $HOSTNAME\", \"message\": \"$message\"}"
}
# Check if the server file exists
@@ -22,7 +22,7 @@ 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" "❌ Server file not found: $SERVER_FILE"
+ send_notify "" "❌ Server file not found: $SERVER_FILE"
SERVER_OK=0
fi
@@ -59,20 +59,20 @@ REMOTE_HOST="nas.haven"
REMOTE_DIR="/export/Backup/Docker/$(cat /etc/hostname)"
# Create a compressed backup file
-if ! zip -r $BACKUP_FILE $SOURCE_DIR; then
- send_notify "Backup Error" "❌ Failed to create backup archive for: $SOURCE_DIR"
- exit 1
+zip -q -r $BACKUP_FILE $SOURCE_DIR || true
+if [ $? -ne 0 ]; then
+ send_notify "" "⚠️ Some files or folders in $SOURCE_DIR could not be backed up (possibly in use or locked). Backup archive created with available files."
fi
# Check if remote path exists
if ! ssh $REMOTE_USER@$REMOTE_HOST "mkdir -p $REMOTE_DIR"; then
- send_notify "[Docker Backup][$HOSTNAME] Error" "❌ Failed to create remote directory: $REMOTE_DIR on $REMOTE_HOST"
+ send_notify "" "❌ Failed to create remote directory: $REMOTE_DIR on $REMOTE_HOST"
exit 1
fi
# Transfer the backup file to the remote server
if ! scp $BACKUP_FILE $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR; then
- send_notify "[Docker Backup][$HOSTNAME] Error" "❌ Failed to transfer backup file to remote server: $REMOTE_HOST:$REMOTE_DIR"
+ send_notify "" "❌ Failed to transfer backup file to remote server: $REMOTE_HOST:$REMOTE_DIR"
exit 1
fi
@@ -81,11 +81,11 @@ rm $BACKUP_FILE
# Erase last 7 days backups from remote server
if ! ssh $REMOTE_USER@$REMOTE_HOST "find $REMOTE_DIR -type f -name 'docker_backup_*' -mtime +7 -exec rm {} \;"; then
- send_notify "[Docker Backup][$HOSTNAME] Warning" "⚠️ Failed to clean old backups on remote server: $REMOTE_HOST:$REMOTE_DIR"
+ send_notify "" "⚠️ Failed to clean old backups on remote server: $REMOTE_HOST:$REMOTE_DIR"
fi
# Success notification
-send_notify "[Docker Backup][$HOSTNAME] Success" "✅ Backup completed successfully for: $SOURCE_DIR to $REMOTE_HOST:$REMOTE_DIR"
+send_notify "" "✅ Backup completed successfully for: $SOURCE_DIR to $REMOTE_HOST:$REMOTE_DIR"
echo "Backup completed successfully"
exit 0