Добавлено удаление старых архивов

This commit is contained in:
stirelshka8_BigARM 2025-02-18 13:47:23 +03:00
parent 516b9299ce
commit 651d95e71c
2 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,7 @@ SKIP_DIRS=
DIRS=/etc,/var/log
FILES=/home/user/BashProject/backup.sh,/home/user/jet/restore.sh
[FTP]
DAYS_TO_KEEP=7
FTP_SERVER=127.0.0.1
FTP_USER=user
FTP_PASS=password

View File

@ -112,6 +112,7 @@ TAR_NAME="BACKUP_$(hostname)_$TIMESTAMP.tar.gz"
FTP_SERVER="$(get_ini_value "FTP" "FTP_SERVER")"
FTP_USER="$(get_ini_value "FTP" "FTP_USER")"
FTP_PASS="$(get_ini_value "FTP" "FTP_PASS")"
DAYS_TO_KEEP="$(get_ini_value "FTP" "DAYS_TO_KEEP")"
# Создаем временную директорию
mkdir -p "$TEMP_DIR"
@ -188,13 +189,14 @@ if [[ ! -f "$LOG_FILE" ]]; then
fi
# Загружаем файлы на FTP-сервер
echo "Sending files ..." >> "$LOG_FILE"
echo "Deleting old files and sending files ..." >> "$LOG_FILE"
lftp -u "$FTP_USER","$FTP_PASS" "$FTP_SERVER" <<EOF > ftp_log.txt 2>&1
set ssl:verify-certificate no
set net:timeout 10
set net:max-retries 3
set net:reconnect-interval-base 5
set net:reconnect-interval-multiplier 2
find . -type f -mtime +$DAYS_TO_KEEP -exec rm {} ;
put "$TAR_NAME"
put "$LOG_FILE"
bye