Fix trap error

main
Anthony 2025-01-06 23:18:14 +08:00
parent 1642074673
commit 716fcce79c
1 changed files with 6 additions and 2 deletions

View File

@ -2,8 +2,13 @@
# Enable error handling
set -e
trap 'echo "[$(date +'%Y-%m-%d %H:%M:%S')] Backup failed" >> "$LOG_DIR/backup_error.log"' ERR
# Define log file path
LOG_DIR="/home/jelastic/mb-backups/logs"
mkdir -p "$LOG_DIR"
# Properly escape the trap command
trap 'echo "[$(date +'\''%Y-%m-%d %H:%M:%S'\'')] Backup failed" >> "$LOG_DIR/backup_error.log"' ERR
# Load the backup logic functions
source /home/jelastic/mb-backups/backup-logic.sh
@ -12,7 +17,6 @@ password_file="/etc/restic-password"
APP_PATH='/var/www/webroot/ROOT'
WP_CONFIG="${APP_PATH}/wp-config.php"
backupPath='/mnt/backups'
LOG_DIR="/home/jelastic/mb-backups/logs"
TEMP_DIR="/tmp/wp_backup_tmp"
MAX_BACKUP_SIZE=$((10 * 1024 * 1024 * 1024)) # 10GB