Устранение ошибок

This commit is contained in:
stirelshka8 2025-02-06 21:12:11 +03:00
parent 8a3e19fb25
commit 38e6b73bd1
2 changed files with 29 additions and 22 deletions

View File

@ -31,24 +31,26 @@
<h3>▎Пример файла backup.ini</h1> <h3>▎Пример файла backup.ini</h1>
``` ini ``` ini
[SENT]
TELEGRAM_TOKEN=ваш_телеграм_токен
CHAT_ID=ваш_chat_id
GOTIFY_URL=http://ваш_адрес_gotify
GOTIFY_APP_TOKEN=ваш_gotify_app_token
[Backup] [Backup]
DIRS=/path/to/dir1,/path/to/dir2
FILES=/path/to/file1,/path/to/file2
SKIP_FILES=/path/to/skip_file1,/path/to/skip_file2
SKIP_DIRS=/path/to/skip_dir1,/path/to/skip_dir2
ENABLE_DIRS=true ENABLE_DIRS=true
ENABLE_FILES=true ENABLE_FILES=false
SKIP_FILES=
SKIP_DIRS=
DIRS=/etc,/var/log
FILES=/home/user/BashProject/backup.sh,/home/user/jet/restore.sh
[FTP] [FTP]
FTP_SERVER=ftp://ваш_ftp_сервер FTP_SERVER=127.0.0.1
FTP_USER=ваш_пользователь FTP_USER=user
FTP_PASS=ваш_пароль FTP_PASS=password
[SENT]
ENABLE_SENT=true
ENABLE_SENT_GOTIFY=true
ENABLE_SENT_TELEGRAM=true
GOTIFY_URL=http://ваш_gotify_сервер
GOTIFY_APP_TOKEN=0000000
TELEGRAM_TOKEN=00000000
CHAT_ID=00000000
TEXT_FINISH_MESSAGE="Backup finished"
[END] [END]
``` ```
<h3>▎Описание переменных</h1> <h3>▎Описание переменных</h1>

View File

@ -7,7 +7,9 @@
WORK_DIR="/opt/adminlabs_backup" WORK_DIR="/opt/adminlabs_backup"
CONFIG_DIR="$WORK_DIR/backup.ini" CONFIG_DIR="$WORK_DIR/backup.ini"
LOG_FILE="$WORK_DIR/backup_log_$(date +"%Y-%m-%d_%H-%M-%S").txt" LOG_FILE="$WORK_DIR/backup_log_$(hostname)_$(date +"%Y-%m-%d_%H-%M-%S").txt"
cd $WORK_DIR
mkdir -p "$WORK_DIR" mkdir -p "$WORK_DIR"
@ -192,8 +194,8 @@ set net:timeout 10
set net:max-retries 3 set net:max-retries 3
set net:reconnect-interval-base 5 set net:reconnect-interval-base 5
set net:reconnect-interval-multiplier 2 set net:reconnect-interval-multiplier 2
put "$WORK_DIR/$TAR_NAME" put "$TAR_NAME"
put "$WORK_DIR/$LOG_FILE" put "$LOG_FILE"
bye bye
EOF EOF
@ -207,13 +209,16 @@ else
fi fi
# Удаление временной директории и архива после завершения работы скрипта # Удаление временной директории и архива после завершения работы скрипта
rm -rf "$TEMP_DIR" || { echo "Error while deleting temp directory."} rm -rf "$TEMP_DIR" || echo "Error while deleting temp directory."
echo "Temp directory deleted." echo "Temp directory deleted."
rm "$WORK_DIR/$TAR_NAME" || { echo "Error while deleting tar.gz archive."} rm "$TAR_NAME" || echo "Error while deleting tar.gz archive."
echo "Tar.gz archive deleted." echo "Tar.gz archive deleted."
rm "$WORK_DIR/$LOG_FILE" || { echo "Error while deleting log file."} rm "$LOG_FILE" || echo "Error while deleting log file."
echo "Log file deleted." echo "Log file deleted."
echo "Sending message..." echo "Sending message..."
get_sent_message "$(get_ini_value "SENT" "TEXT_FINISH_MESSAGE")" || echo "Error while sending message." get_sent_message "$(get_ini_value "SENT" "TEXT_FINISH_MESSAGE")" || echo "Error while sending message."
echo "Backup completed." echo "Backup completed."
cd ~
exit 0