From 651d95e71c970813492e59e5e650cd8bd089a249 Mon Sep 17 00:00:00 2001 From: stirelshka8_BigARM Date: Tue, 18 Feb 2025 13:47:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D1=81=D1=82=D0=B0=D1=80=D1=8B=D1=85=20=D0=B0=D1=80=D1=85?= =?UTF-8?q?=D0=B8=D0=B2=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup.ini | 1 + backup.sh | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backup.ini b/backup.ini index e2aabc4..cd3770b 100644 --- a/backup.ini +++ b/backup.ini @@ -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 diff --git a/backup.sh b/backup.sh index e59c15f..1f7fa25 100755 --- a/backup.sh +++ b/backup.sh @@ -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" < 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 -- 2.45.2