shell 备份指定目录下的增量文件
2017-08-18 10:09
323 查看
其中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
#!/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
相关文章推荐
- 把远程linux服务器上的指定目录下的所有文件,增量备份到本地服务器上
- shell查找指定目录下的关键字文件
- 压缩指定目录文件到指定目录的批处理【加上计划任务,可做定制备份】
- shell备份,重命名,删除目录下面的文件
- shell遍历目录下指定后缀名的文件
- shell-删除目录下指定日期前的所有文件
- Python实现目录文件的全量和增量备份
- 编写一个SHELL脚本,可以获得指定目录下的所有文件及文件夹的大小。输出的样式与 ls -lh 命令相同。
- shell脚本,对指定目录下C文件,替换和删除字符串
- shell备份文件、重命名文件、删除指定文件的3个脚本分享
- 批处理向FTP上传具有指定属性的文件(增量备份)
- shell 删除目录及子目录指定类型的文件
- Shell脚本:使用rsync备份文件/目录
- shell 脚本 打印指定目录下包含某些字符串的文件
- shell删除当前目录及递归目录下文件指定字符串
- 使用ShellExcecute打开指定目录并选中指定文件的方法
- 启动shell的调试模式 set -x ,find 当前目录下的指定类型文件
- 通过 winrar 备份指定目录,日备、周备、月备,过往文件存在就覆盖
- shell 定时删除某个目录指定格式文件(递归)
- Vbs程序备份指定文件到指定目录并且以日期重命名