Устранение ошибок
This commit is contained in:
parent
8a3e19fb25
commit
38e6b73bd1
32
README.md
32
README.md
@ -31,24 +31,26 @@
|
||||
<h3>▎Пример файла backup.ini</h1>
|
||||
|
||||
``` ini
|
||||
[SENT]
|
||||
TELEGRAM_TOKEN=ваш_телеграм_токен
|
||||
CHAT_ID=ваш_chat_id
|
||||
GOTIFY_URL=http://ваш_адрес_gotify
|
||||
GOTIFY_APP_TOKEN=ваш_gotify_app_token
|
||||
|
||||
[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_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_SERVER=ftp://ваш_ftp_сервер
|
||||
FTP_USER=ваш_пользователь
|
||||
FTP_PASS=ваш_пароль
|
||||
FTP_SERVER=127.0.0.1
|
||||
FTP_USER=user
|
||||
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]
|
||||
```
|
||||
<h3>▎Описание переменных</h1>
|
||||
|
19
backup.sh
19
backup.sh
@ -7,7 +7,9 @@
|
||||
|
||||
WORK_DIR="/opt/adminlabs_backup"
|
||||
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"
|
||||
|
||||
@ -192,8 +194,8 @@ set net:timeout 10
|
||||
set net:max-retries 3
|
||||
set net:reconnect-interval-base 5
|
||||
set net:reconnect-interval-multiplier 2
|
||||
put "$WORK_DIR/$TAR_NAME"
|
||||
put "$WORK_DIR/$LOG_FILE"
|
||||
put "$TAR_NAME"
|
||||
put "$LOG_FILE"
|
||||
bye
|
||||
EOF
|
||||
|
||||
@ -207,13 +209,16 @@ else
|
||||
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."
|
||||
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."
|
||||
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 "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
|
||||
|
Loading…
Reference in New Issue
Block a user