updating backup.sh
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 2s
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 2s
This commit is contained in:
12
backup.sh
12
backup.sh
@@ -6,10 +6,6 @@ SERVER_FILE="https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/backup.
|
|||||||
SERVER_OK=1
|
SERVER_OK=1
|
||||||
HOSTNAME=$(cat /etc/hostname)
|
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"
|
NOTIFY_URL="http://notify.haven"
|
||||||
|
|
||||||
# Function to send notification
|
# Function to send notification
|
||||||
@@ -20,6 +16,11 @@ send_notify() {
|
|||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"title\": \"$title\", \"message\": \"$message\"}"
|
-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
|
echo "Error: $SERVER_FILE not found." >&2
|
||||||
send_notify "[Docker Backup][$HOSTNAME] Error" "❌ <span style='color:red'>Server file not found:</span> $SERVER_FILE"
|
send_notify "[Docker Backup][$HOSTNAME] Error" "❌ <span style='color:red'>Server file not found:</span> $SERVER_FILE"
|
||||||
SERVER_OK=0
|
SERVER_OK=0
|
||||||
@@ -57,9 +58,6 @@ REMOTE_USER="ivanch"
|
|||||||
REMOTE_HOST="nas.haven"
|
REMOTE_HOST="nas.haven"
|
||||||
REMOTE_DIR="/export/Backup/Docker/$(cat /etc/hostname)"
|
REMOTE_DIR="/export/Backup/Docker/$(cat /etc/hostname)"
|
||||||
|
|
||||||
# Create a compressed backup file
|
|
||||||
zip -r $BACKUP_FILE $SOURCE_DIR
|
|
||||||
|
|
||||||
# Create a compressed backup file
|
# Create a compressed backup file
|
||||||
if ! zip -r $BACKUP_FILE $SOURCE_DIR; then
|
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"
|
send_notify "Backup Error" "❌ <span style='color:red'>Failed to create backup archive for:</span> $SOURCE_DIR"
|
||||||
|
Reference in New Issue
Block a user