脚本内容: #!/bin/bash dn=`dirname $0` cd $dn awk '/^[^#]/' rsync_dir.txt | while read line do i=1 dirarr=($line) len=${#dirarr[@]} if [ $len -gt 1 ] ; then ipa=${dirarr[0]} if ping -c 2 $ipa >/dev/null ;then echo "$ipa is alive" else echo "$ipa is not alive" continue fi else echo "input \'$line\' is error" continue fi while [ $i -lt $len ] do res=${dirarr[$i]} if ssh $ipa "[[ -d $res ]]" </dev/null ; then dir=/backup_static_files/`date '+%Y%m%d'`/${ipa}${res} [[ ! -d $dir ]] && mkdir -pv $dir rsync -auvrtzopgP -e ssh $ipa:$res/ $dir elif ssh $ipa "[[ -f $res ]]" </dev/null ; then dir=/backup_static_files/`date '+%Y%m%d'`/${ipa}`dirname $res` [[ ! -d $dir ]] && mkdir -pv $dir rsync -auvrtzopgP -e ssh $ipa:$res $dir else echo "$res is not exist" fi i=$(($i+1)) done done 文件rsync_dir.txt内容: # ServerIp StaticFilesDir ... 10.10.45.82 /root/.ssh /usr/local/tomcatcluster /usr/local/nginx 10.10.1.142 /root/cut-apache /etc/httpd/conf /etc/httpd/conf.d /opt/IBM/WebSphere/Plugins/config/plugsrv /root/qiehuan1143.sh
通过rsync备份静态文件
原创ConfusedSnail 博主文章分类:Shell ©著作权
©著作权归作者所有:来自51CTO博客作者ConfusedSnail的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
数据同步--rsync
使用rsync进行两台或多台主机直接的数据同步
rsync数据同步 -
vscode+extendscript编写ps文件自动备份脚本
ps文件自动备份
json javascript Photoshop extendscript 文件备份 -
rsync备份多个文件 rsync差异备份
rsync备份工具一、scpscp备份工具不可以进行增量备份1、安装scp[root@chenglinux ~]# yum install -y openssh-clients2
rsync备份多个文件 操作系统 运维 开发工具 linux -
rsync 文件夹备份 rsync全量备份
目录 rsync同步工具1、rsync介绍 2、rsync特性 3、rsync工作场景 4、rsync命令同步参数选项rsync同步工具1、rsync介绍rsync是一款开源的、快速的、多功能
rsync 文件夹备份 linux 数据 数据同步 文件属性