#!/bin/bash # Check for required arguments if [ $# -ne 2 ]; then echo "Usage: $0 " exit 1 fi # Assign arguments to variables RESTIC_PASSWORD="$1" ADDITIONAL_TAG="$2" # Configuration APP_PATH='/var/www/webroot/ROOT' backupPath='/mnt/backups' LOG_DIR="/home/jelastic/mb-backups/logs" LOG_FILE="${LOG_DIR}/backup_core_files_$(date +'%Y-%m-%d').log" excludePaths=( "$APP_PATH/wp-content/uploads" ) # Ensure log directory exists mkdir -p "$LOG_DIR" # Set Restic environment variables export RESTIC_REPOSITORY="$backupPath" export RESTIC_PASSWORD # Logging start echo "[$(date +'%Y-%m-%d %H:%M:%S')] Starting Core Files Backup with tags: core_files, $ADDITIONAL_TAG" | tee -a "$LOG_FILE" # Building exclude options excludeOptions="" for path in "${excludePaths[@]}"; do excludeOptions+="--exclude $path " done # Perform backup with both tags if restic backup $excludeOptions "$APP_PATH" --tag core_files --tag "$ADDITIONAL_TAG"; then echo "[$(date +'%Y-%m-%d %H:%M:%S')] Core files backup completed successfully." | tee -a "$LOG_FILE" else echo "[$(date +'%Y-%m-%d %H:%M:%S')] ERROR: Core files backup failed." | tee -a "$LOG_FILE" fi # Logging end echo "[$(date +'%Y-%m-%d %H:%M:%S')] Backup process finished." | tee -a "$LOG_FILE"