shell 备份指定目录下的增量文件

来源:互联网 发布:mac 源码安装php7 编辑:程序博客网 时间:2024/06/10 04:04

其中xxx.xxx.xxx.xxx为IP地址

#!/bin/bash

list=`ls /opt/sftp/ ` 
time=`date "+%Y%m%d%H%M%S"`
today=`date "+%Y%m%d"`
cfgfile="/root/shell/conf/data_backup.cfg"
logfile="/root/shell/logs/data_backup_${today}.log"
passwordfile="/root/shell/conf/data.rsync"
input_home="/opt/sftp"
ps=`ps x |grep -v grep|grep rsync_ftpdata.sh|wc -l`
if [[ $ps -le 3 ]];then
for sourcepath in $list
do
        cd ${input_home}
#        rsyncfile=`find ${sourcepath} -type f `
        rsyncfile=`find ${sourcepath} -type f  -mmin -60 -mmin +10`
                if [ -n "$rsyncfile" ];then
                        echo $rsyncfile
                        for okfile in $rsyncfile
                                do
                                       rsync -abvRurczP  --suffix=.$time --password-file=${passwordfile} ${okfile} migu_data@xxx.xxx.xxxx.xxx::migu_data/sftp/xxx.xxx.xxx.xxx/
                                        if [ $? == 0 ]
                                then
                                        echo -e "####ʱime  ${okfile} #####\n" >> ${logfile}
                                else
                                        echo -e "####ʱime  ${okfile} ʧ#\n" >> ${logfile}
                                        fi
                                done
                else
                        echo "$time  NO new file exist in ${sourcepath}" >> ${logfile}
                fi
done 
exit
else
echo -e "process is exist,process number is $ps" >> ${logfile}
exit
fi
阅读全文
0 0
原创粉丝点击