rsync同步
来源:互联网 发布:java 枚举接口 编辑:程序博客网 时间:2024/05/01 23:00
环境:
vmwara两台linux虚拟机
系统:SUSE linux 11 SP3
A机:172.27.34.210 B机:172.27.34.211
主机配置这里略过,IP配好基本ok
第一步:SSH配置
AB 两台主机开启SSHD服务,一般默认安装了,开启服务,并且禁用防火墙就行。
第二步:rsync服务
开启rsync服务 在 vi /etc/xinetd.d/rsync中 将 “disable=yes”改为“disable=no”
chkconfig rsync检验
第三步:运行rsync脚本
#!/bin/bash
backupf='/home/qwt/bckup.txt'
echo "Shell Script Backup Your Files / Directories Using rsync"
while [ x$desthost = "x" ]; do
read -p "Destination backup Server : " desthost
done
while [ x$destpath = "x" ]; do
read -p "Destination Folder : " destpath
done
for line in `cat $backupf`
do
echo "Copying $line ... "
rsync -ar "$line" "$desthost":"$destpath"
echo "DONE"
done
其中bckup.txt中包含需要同步的文件以及路径如:
/home/qwt/1.txt
/home/qwt/2.sh
/home/qwt/docs
这里会报一个错误:Copying /home/qwt/1.txt ...
The authenticity of host '172.27.34.211 (172.27.34.211)' can't be established.
ECDSA key fingerprint is 40:c2:34:00:0a:1e:51:c1:57:85:cb:01:7e:2d:2e:f8 [MD5].
Are you sure you want to continue connecting (yes/no)?
查阅网上资料,在绝对信任的主机之间可以采用以下方法屏蔽该错误提示
修改/etc/ssh/ssh_config文件
在最后加上 StrictHostKeyChecking no
UserKnownHostsFile /dev/null
再次运行 bash rsync.sh
先提示输入目的IP:
再提示输入目的路径:
DONE
Shell Script Backup Your Files / Directories Using rsync
Destination backup Server : 172.27.34.211
Destination Folder : /home/qwt
Copying /home/qwt/1.txt ...
Warning: Permanently added '172.27.34.211' (ECDSA) to the list of known hosts.
Password:
DONE
Copying /home/qwt/2.sh ...
Warning: Permanently added '172.27.34.211' (ECDSA) to the list of known hosts.
Password:
DONE
Copying /home/qwt/docs ...
Warning: Permanently added '172.27.34.211' (ECDSA) to the list of known hosts.
Password:
DONE
这里一共同步了三个文件,所以输入了三次密码。。。
- rsync同步
- rsync 同步
- rsync同步
- rsync同步
- rsync同步
- rsync同步
- rsync同步
- rsync同步
- lsyncd+rsync实时同步rsync同步
- rsync 同步使用详解
- rsync搭建同步策略
- Rsync+ssh同步服务器
- rsync同步专题
- rsync数据同步备份
- rsync同步软件
- Rsync实现文件夹同步
- rsync 同步使用详解
- rsync文件同步配置
- HDU2437 2008 Asia Chengdu Regional Contest Online 记忆化搜索+剪枝
- HDU-1166(线段树-单点更新)
- 数据结构上机实验之二分查找
- TextView省略&相关处理
- 关联规则算法(The Apriori algorithm)详解
- rsync同步
- 等价、偏序和全序
- QT常用知识
- [JZOJ4680] 自然数 [HDU4747] Mex
- 抽象工厂模式
- C#中的枚举类型(enum type)
- python pygame实战《飞船大战外星人》
- 【Sublime】Mac下Sublime代码自动换行
- npm常用命令