- 1. 客户端脚本
- 2. 服务器端的脚本
- 3. sersync2自动的数据同步
#!/bin/bash yum -y install rsync &>dev/null echo "123456" > /etc/rsync.password chmod 600 /etc/rsync.password echo "ok ...."
测试:
2. 服务器端的脚本#!/bin/bash yum -y install rsync &>/dev/null [ $? -eq 0 ] && echo "rsync install ok..." systemctl start rsyncd &>/dev/null systemctl enable rsyncd &>/dev/null #配置文件 cat > /etc/rsyncd.conf </etc/rsync.password chmod 600 /etc/rsync.password #创建备份目录 mkdir -p /backup chown -R rsync.rsync /backup systemctl restart rsyncd &>/dev/null [ $? -eq 0 ] && echo "restart is ok ... "
测试:
rsync -avz /etc/hosts rsync_backup@192.168.80.31::backup --password-file=/etc/rsync.password3. sersync2自动的数据同步
下载压缩包:https://pan.baidu.com/s/1PtOlqdFgOzqhWDCse-6fHA
链接:https://pan.baidu.com/s/1PtOlqdFgOzqhWDCse-6fHA
提取码:8dda
rz -E tar xf mv .. sersync mv sersync /usr/local/ cd /usr/local/sersync vim confxml.xml
| wath | 客户端的要进行数据同步的目录 |
|---|---|
| ip | 备份服务器的ip地址,可以是内网 ,这里可以配置多个 |
| name | rsync里边的模块 |
| params | rsync的传输方式az就可以 |
| start | true启动 |
| user | rsync的密码文件的用户 |
| password | 密码文件的位置 |
| port | 默认端口号874,改为true与rsync的配置文件一致 |
| time | 连接时间,超时 |
启动
cp /usr/local/sersync/sersync2 /usr/bin 启动 sersync2 -dro /usr/loacl/sersync/confxml.xml 关闭 ps -ef | grep sersync2 kill -9



