Обновлен скрипт
This commit is contained in:
parent
170d5dd6e8
commit
0cc2386430
@ -6,6 +6,7 @@
|
|||||||
#Version: 0.0.1test
|
#Version: 0.0.1test
|
||||||
|
|
||||||
WORK_DIR="/opt/adminlabs_backup"
|
WORK_DIR="/opt/adminlabs_backup"
|
||||||
|
TEMP_DIR="/tmp/backup_$TIMESTAMP"
|
||||||
CONFIG_DIR="$WORK_DIR/backup.ini"
|
CONFIG_DIR="$WORK_DIR/backup.ini"
|
||||||
LOG_FILE="$WORK_DIR/backup_log_$(hostname)_$(date +"%Y-%m-%d_%H-%M-%S").txt"
|
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_DIRS=$(get_ini_value "Backup" "ENABLE_DIRS")
|
||||||
ENABLE_FILES=$(get_ini_value "Backup" "ENABLE_FILES")
|
ENABLE_FILES=$(get_ini_value "Backup" "ENABLE_FILES")
|
||||||
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
|
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
|
||||||
TEMP_DIR="/tmp/backup_$TIMESTAMP"
|
|
||||||
TAR_NAME="BACKUP_$(hostname)_$TIMESTAMP.tar.gz"
|
TAR_NAME="BACKUP_$(hostname)_$TIMESTAMP.tar.gz"
|
||||||
FTP_SERVER="$(get_ini_value "FTP" "FTP_SERVER")"
|
FTP_SERVER="$(get_ini_value "FTP" "FTP_SERVER")"
|
||||||
FTP_USER="$(get_ini_value "FTP" "FTP_USER")"
|
FTP_USER="$(get_ini_value "FTP" "FTP_USER")"
|
||||||
@ -140,7 +140,7 @@ if [[ "$ENABLE_DIRS" == "true" ]]; then
|
|||||||
continue 2 # Пропускаем всю директорию, если найдено исключение
|
continue 2 # Пропускаем всю директорию, если найдено исключение
|
||||||
fi
|
fi
|
||||||
done
|
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"
|
cp -r "$DIR" "$TEMP_DIR/" && echo "Copy directory $DIR completed." >> "$LOG_FILE" || echo "Error while copying directory $DIR." >> "$LOG_FILE"
|
||||||
else
|
else
|
||||||
echo "Directory $DIR not found, skipping." >> "$LOG_FILE"
|
echo "Directory $DIR not found, skipping." >> "$LOG_FILE"
|
||||||
@ -171,9 +171,10 @@ else
|
|||||||
echo "Backup of files is disabled." >> "$LOG_FILE"
|
echo "Backup of files is disabled." >> "$LOG_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Упаковываем временную директорию в tar.gz архив
|
# Упаковываем временную директорию в 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
|
if [[ ! -f "$TAR_NAME" ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user