Данный bash-скрипт копирует резервные копии сайта за последние 5 дней их облачного сервера на ваш компьютер и удаляет старые. В итоге у вас всегда будут хранится только 5 последних. ✅
.env
HOST=hostname #This is the FTP servers host or IP address.
USER=username #This is the FTP user that has access to the server.
PASS=userpass #This is the password for the FTP user.
REMOTE_PATH=remotepath
init.sh
#!/bin/bash
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"
. ./.env
wget -N -nd -r "ftp://$USER:$PASS@$HOST/"
read -p "Удалить последние файлы (y/n)?" CONT
if [ "$CONT" = "y" ]; then
find ./ -name "*.tar.gz" -mtime +4 -type f -delete;
find ./ -name "*.sql" -mtime +4 -type f -delete;
else
echo "Отмена";
fi