From 8ae80c34b1364416687f1500ffcfcbe603cda166 Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 18 Jul 2025 01:25:40 +0800 Subject: [PATCH] Update /data folder --- changelogs.md | 2 +- readme.md | 2 +- scripts/backup-logic.sh | 2 +- scripts/backup-main.js | 2 +- scripts/imports/backup_core_files.sh | 2 +- scripts/imports/backup_database.sh | 2 +- scripts/imports/backup_media.sh | 4 ++-- scripts/imports/check_backup_repo.sh | 2 +- scripts/imports/check_repo_stats.sh | 2 +- scripts/imports/restore_backup_direct.sh | 2 +- scripts/imports/restore_full_backup_session.sh | 2 +- scripts/imports/view_backup_sessions.sh | 2 +- scripts/imports/view_snapshots.sh | 2 +- scripts/install-restic.sh | 6 ++---- scripts/mb-backup-manager.js | 8 ++++---- 15 files changed, 20 insertions(+), 22 deletions(-) diff --git a/changelogs.md b/changelogs.md index 77d099f..42e2a27 100644 --- a/changelogs.md +++ b/changelogs.md @@ -14,7 +14,7 @@ ### Fixed - Resolved issues with fetching available tags when no snapshots existed in the repository, ensuring consistent script behavior. -- Fixed a missing password issue when executing `restic -r /data/backups snapshots --json`, ensuring `RESTIC_PASSWORD` is securely passed in all cases. +- Fixed a missing password issue when executing `restic -r /data snapshots --json`, ensuring `RESTIC_PASSWORD` is securely passed in all cases. - Corrected formatting and display of available tags to ensure no duplicate or unnecessary entries are shown. ### Updated diff --git a/readme.md b/readme.md index 000ea51..dbcac2b 100644 --- a/readme.md +++ b/readme.md @@ -280,7 +280,7 @@ Displays current backup-related cron jobs and automation status. The following environment variables are used by the scripts: - `RESTIC_PASSWORD`: Stored in `/etc/restic-password` -- `RESTIC_REPOSITORY`: Default path `/data/backups` +- `RESTIC_REPOSITORY`: Default path `/data` ### Log File Locations diff --git a/scripts/backup-logic.sh b/scripts/backup-logic.sh index 0218bbe..588822a 100644 --- a/scripts/backup-logic.sh +++ b/scripts/backup-logic.sh @@ -15,7 +15,7 @@ COMMAND="$2" # Set dynamic configurations based on ENV_NAME LOG_FILE="/var/log/${ENV_NAME}_backup_script.log" -BACKUP_REPO_PATH="/data/backups/${ENV_NAME}" +BACKUP_REPO_PATH="/data" PASSWORD_FILE="/etc/restic-password" LOCK_FILE="/tmp/restic_global.lock" diff --git a/scripts/backup-main.js b/scripts/backup-main.js index 2161606..e8d4de7 100644 --- a/scripts/backup-main.js +++ b/scripts/backup-main.js @@ -13,7 +13,7 @@ function run() { envName : "${envName}", envAppid : "${envAppid}", backupCount : "${backupCount}", - backupPath : "/data/backups" + backupPath : "/data" }); api.local.ReturnResult( diff --git a/scripts/imports/backup_core_files.sh b/scripts/imports/backup_core_files.sh index f5ffe40..56b78fd 100644 --- a/scripts/imports/backup_core_files.sh +++ b/scripts/imports/backup_core_files.sh @@ -22,7 +22,7 @@ CUSTOM_LABEL="$2" # Configuration APP_PATH="/var/www/webroot/ROOT" -BACKUP_PATH="/data/backups" +BACKUP_PATH="/data" PASSWORD_FILE="/etc/restic-password" LOG_DIR="/home/jelastic/mb-backups/logs" LOG_FILE="${LOG_DIR}/backup_core_files_$(date +'%Y-%m-%d').log" diff --git a/scripts/imports/backup_database.sh b/scripts/imports/backup_database.sh index abf4536..3ca14f7 100644 --- a/scripts/imports/backup_database.sh +++ b/scripts/imports/backup_database.sh @@ -16,7 +16,7 @@ CUSTOM_TAG="$2" # Configuration APP_PATH='/var/www/webroot/ROOT' WP_CONFIG="${APP_PATH}/wp-config.php" -BACKUP_PATH='/data/backups' +BACKUP_PATH='/data' PASSWORD_FILE="/etc/restic-password" LOG_DIR="/home/jelastic/mb-backups/logs" LOG_FILE="${LOG_DIR}/backup_database_$(date +'%Y-%m-%d').log" diff --git a/scripts/imports/backup_media.sh b/scripts/imports/backup_media.sh index 5d0f5a7..9f9f5e2 100644 --- a/scripts/imports/backup_media.sh +++ b/scripts/imports/backup_media.sh @@ -15,7 +15,7 @@ CUSTOM_TAG="$2" # Configuration APP_PATH='/var/www/webroot/ROOT' -BACKUP_PATH='/data/backups' +BACKUP_PATH='/data' PASSWORD_FILE="/etc/restic-password" LOG_DIR="/home/jelastic/mb-backups/logs/manual/media" LOG_FILE="${LOG_DIR}/backup_media_$(date +'%Y-%m-%d').log" @@ -66,7 +66,7 @@ else log "No stale locks found." fi -# Check and fix permissions on /data/backups +# Check and fix permissions on /data if [ ! -w "$BACKUP_PATH/locks" ]; then log "Fixing permissions on $BACKUP_PATH/locks" sudo chown -R litespeed:litespeed "$BACKUP_PATH/locks" diff --git a/scripts/imports/check_backup_repo.sh b/scripts/imports/check_backup_repo.sh index 361e84d..2a46a51 100644 --- a/scripts/imports/check_backup_repo.sh +++ b/scripts/imports/check_backup_repo.sh @@ -4,7 +4,7 @@ set -e # Configuration -BACKUP_REPO_PATH="/data/backups" +BACKUP_REPO_PATH="/data" PASSWORD_FILE="/etc/restic-password" LOG_FILE="/var/log/backup_repo_check.log" diff --git a/scripts/imports/check_repo_stats.sh b/scripts/imports/check_repo_stats.sh index e3f75f3..6c3630b 100644 --- a/scripts/imports/check_repo_stats.sh +++ b/scripts/imports/check_repo_stats.sh @@ -4,7 +4,7 @@ set -e # Configuration -BACKUP_REPO_PATH="/data/backups" +BACKUP_REPO_PATH="/data" PASSWORD_FILE="/etc/restic-password" LOG_DIR="/home/litespeed/mb-backups/logs" LOG_FILE="${LOG_DIR}/repo_stats_$(date +'%Y-%m-%d').log" diff --git a/scripts/imports/restore_backup_direct.sh b/scripts/imports/restore_backup_direct.sh index b8cd342..e6bfb6e 100644 --- a/scripts/imports/restore_backup_direct.sh +++ b/scripts/imports/restore_backup_direct.sh @@ -13,7 +13,7 @@ fi # Assign input to variables SNAPSHOT_ID=$1 RESTIC_PASSWORD_FILE="/etc/restic-password" -RESTIC_REPOSITORY="/data/backups" +RESTIC_REPOSITORY="/data" LOG_DIR="/home/jelastic/mb-backups/logs/restore" WP_CONFIG="/var/www/webroot/ROOT/wp-config.php" diff --git a/scripts/imports/restore_full_backup_session.sh b/scripts/imports/restore_full_backup_session.sh index 064574b..ecd3c67 100644 --- a/scripts/imports/restore_full_backup_session.sh +++ b/scripts/imports/restore_full_backup_session.sh @@ -18,7 +18,7 @@ fi # Assign input to variables BACKUP_SESSION_TAG="$1" RESTIC_PASSWORD_FILE="/etc/restic-password" -RESTIC_REPOSITORY="/data/backups" +RESTIC_REPOSITORY="/data" LOG_DIR="/home/jelastic/mb-backups/logs/restore" WP_CONFIG="/var/www/webroot/ROOT/wp-config.php" TEMP_VALIDATION_DIR="/tmp/full_backup_validation_$$" diff --git a/scripts/imports/view_backup_sessions.sh b/scripts/imports/view_backup_sessions.sh index 08c5386..6f0104e 100644 --- a/scripts/imports/view_backup_sessions.sh +++ b/scripts/imports/view_backup_sessions.sh @@ -1,7 +1,7 @@ #!/bin/bash # Configuration -backupPath='/data/backups' +backupPath='/data' password_file="/etc/restic-password" LOG_DIR="$HOME/mb-backups/logs" LOG_FILE="${LOG_DIR}/backup_sessions.log" diff --git a/scripts/imports/view_snapshots.sh b/scripts/imports/view_snapshots.sh index e078e42..704f445 100644 --- a/scripts/imports/view_snapshots.sh +++ b/scripts/imports/view_snapshots.sh @@ -1,7 +1,7 @@ #!/bin/bash # Configuration -backupPath='/data/backups' +backupPath='/data' password_file="/etc/restic-password" LOG_DIR="$HOME/mb-backups/logs" LOG_FILE="${LOG_DIR}/restic_snapshot.log" diff --git a/scripts/install-restic.sh b/scripts/install-restic.sh index fbfe444..d5f57c4 100644 --- a/scripts/install-restic.sh +++ b/scripts/install-restic.sh @@ -25,21 +25,19 @@ chmod 644 /etc/restic-password # Create directories echo "[INSTALL] Creating directories..." -mkdir -p /data/backups mkdir -p /home/litespeed/mb-backups/logs chmod -R 755 /home/litespeed/mb-backups/logs -chmod 755 /data/backups # Initialize repository echo "[INSTALL] Initializing repository..." export RESTIC_PASSWORD=$(cat /etc/restic-password) -export RESTIC_REPOSITORY=/data/backups +export RESTIC_REPOSITORY=/data if restic snapshots >/dev/null 2>&1; then echo "[INSTALL] Repository already exists and is accessible" else echo "[INSTALL] Initializing new repository..." - rm -rf /data/backups/* 2>/dev/null || true + rm -rf /data/* 2>/dev/null || true restic init echo "[INSTALL] Repository initialized successfully" fi diff --git a/scripts/mb-backup-manager.js b/scripts/mb-backup-manager.js index d4d6a91..4ec7be7 100644 --- a/scripts/mb-backup-manager.js +++ b/scripts/mb-backup-manager.js @@ -106,7 +106,7 @@ function BackupManager(config) { backupType: backupType, session: session, email: user.email, - backupPath: "/data/backups" // Direct path to mounted backup storage + backupPath: "/data" // Path to mounted shared storage }; return me.exec([ @@ -395,7 +395,7 @@ function BackupManager(config) { me.backup_wp_core = function () { var backupCallParams = { envName: config.envName, - backupPath: "/data/backups", // Direct path to mounted backup storage + backupPath: "/data", // Path to mounted shared storage baseUrl: config.baseUrl, backupType: "wp_core", backupLogFile: "/var/log/backup_addon.log", @@ -414,7 +414,7 @@ function BackupManager(config) { me.backup_uploads = function () { var backupCallParams = { envName: config.envName, - backupPath: "/data/backups", // Direct path to mounted backup storage + backupPath: "/data", // Path to mounted shared storage baseUrl: config.baseUrl, backupType: "wp_core", backupLogFile: "/var/log/backup_addon.log", @@ -433,7 +433,7 @@ function BackupManager(config) { me.backup_database = function () { var backupCallParams = { envName: config.envName, - backupPath: "/data/backups", // Direct path to mounted backup storage + backupPath: "/data", // Path to mounted shared storage baseUrl: config.baseUrl, backupType: "wp_core", backupLogFile: "/var/log/backup_addon.log",