#!/bin/bash
BACKUP_PATH="/home/hoya/Backup_DB"
DATE=`/bin/date +%Y%m%d%H`
FTP_IP="192.168.1.186"
FTP_PATH="/backup/backup_db/test"
USER=test

PWD=123456

echo -e "=============================================" >> $BACKUP_PATH/rmlist.log
echo -e "$(date "+%Y-%m-%d_%H:%M:%S")\t RM_File List"   >> $BACKUP_PATH/rmlist.log
echo -e "=============================================" >> $BACKUP_PATH/rmlist.log
echo -e "=============================================" >> $BACKUP_PATH/rmlist.log

# 8天之後的欲刪除的備份清單
find $BACKUP_PATH/*.tar.gz -mtime +8 >> $BACKUP_PATH/rmlist.log

# 將欲刪除的備份上傳到 186
find $BACKUP_PATH/*.tar.gz -mtime +8 |while read ftplist

do
lftp -u $USER,$PWD $FTP_IP -e "set xfer:clobber yes;set net:reconnect-interval-base 50;set net:max-retries 50;set net:timeout 50;lcd $BACKUP_PATH;cd $FTP_PATH;put $ftplist;exit"
done

# 8天後的備份不保留
find $BACKUP_PATH/*.tar.gz -mtime +8 -exec rm -f {} \;

neo2124 發表在 痞客邦 PIXNET 留言(0) 人氣()