From 0cc23864303c371025bb38f1d178a1e49fba72f7 Mon Sep 17 00:00:00 2001 From: stirelshka8 Date: Sun, 9 Feb 2025 19:10:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backup.sh b/backup.sh index 00d58ce..e59c15f 100755 --- a/backup.sh +++ b/backup.sh @@ -6,6 +6,7 @@ #Version: 0.0.1test WORK_DIR="/opt/adminlabs_backup" +TEMP_DIR="/tmp/backup_$TIMESTAMP" CONFIG_DIR="$WORK_DIR/backup.ini" LOG_FILE="$WORK_DIR/backup_log_$(hostname)_$(date +"%Y-%m-%d_%H-%M-%S").txt" @@ -107,7 +108,6 @@ SKIP_DIRS=$(get_ini_value "Backup" "SKIP_DIRS") ENABLE_DIRS=$(get_ini_value "Backup" "ENABLE_DIRS") ENABLE_FILES=$(get_ini_value "Backup" "ENABLE_FILES") TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S") -TEMP_DIR="/tmp/backup_$TIMESTAMP" TAR_NAME="BACKUP_$(hostname)_$TIMESTAMP.tar.gz" FTP_SERVER="$(get_ini_value "FTP" "FTP_SERVER")" FTP_USER="$(get_ini_value "FTP" "FTP_USER")" @@ -140,7 +140,7 @@ if [[ "$ENABLE_DIRS" == "true" ]]; then continue 2 # Пропускаем всю директорию, если найдено исключение fi done - + echo "Copy directory $DIR started." cp -r "$DIR" "$TEMP_DIR/" && echo "Copy directory $DIR completed." >> "$LOG_FILE" || echo "Error while copying directory $DIR." >> "$LOG_FILE" else echo "Directory $DIR not found, skipping." >> "$LOG_FILE" @@ -171,9 +171,10 @@ else echo "Backup of files is disabled." >> "$LOG_FILE" fi - # Упаковываем временную директорию в tar.gz архив -tar -czf "$WORK_DIR/$TAR_NAME" -C "$TEMP_DIR" . && echo "Created tar.gz archive: $TAR_NAME" || { echo "Error while creating tar.gz archive."; rm -rf "$TEMP_DIR"; exit 1; } +echo "Creating tar.gz archive..." +tar -czf "$WORK_DIR/$TAR_NAME" -C "$TEMP_DIR" . && echo "Created tar.gz archive: $TAR_NAME" || echo "Error while creating tar.gz archive."; rm -rf "$TEMP_DIR"; exit 1; +echo "Created tar.gz archive: $TAR_NAME" # Проверяем наличие файлов if [[ ! -f "$TAR_NAME" ]]; then