0x01 测试环境
CentOS 7.4 Rsync服务端:192.168.204.130 CentOS 7.4 Rsync客户端:192.168.204.168
0x02 rsync同步方式
第一种方式:rsync通过ssh方式同步
1、Rsync服务端和客户端都需要安装rsync[root@localhost ~]# yum -y install rsync
前提:需知道远程服务器开启ssh端口和账号密码
A、推文件:[root@localhost tmp]# rsync -av /etc/passwd 192.168.204.168:/tmp/passwd.txt

[root@localhost tmp]# rsync -av 192.168.204.168:/tmp/passwd.txt /tmp/test.txt

[root@localhost tmp]# rsync -av -e "ssh -p 22" 192.168.204.168:/tmp/passwd.txt /tmp/a.txt

[root@localhost tmp]# rsync -av -e "ssh -p 22" 192.168.204.168:/tmp/passwd.txt /tmp/a.txt
第二种方式:rsync通过服务的方式同步
服务端配置: 1、编辑配置文件/etc/rsyncd.confmotd file = /etc/rsyncd.motd transfer logging = yes log file = /var/log/rsyncd.log port = 873 address = 192.168.204.130 uid = nobody gid = nobody use chroot = no read only = no max connections = 10 [common] comment = rsync info path = /tmp ignore errors auth users = admin secrets file = /etc/rsyncd.secrets hosts allow = 192.168.204.0/255.255.255.0 hosts deny = * list = false
echo "admin:123456" > /etc/rsyncd.secrets chmod 600 /etc/rsyncd.secrets
echo "rsync info" > /etc/rsyncd.motd
rsync --daemon echo "rsync --daemon" >> /etc/rc.local
echo "123456" > /root/passwd chmod 600 /root/passwd
rsync -avz --password-file=/root/passwd admin@192.168.204.130::common /tmp

rsync -avz --password-file=/root/passwd /tmp/ admin@192.168.204.130::common

rsync -avz --password-file=/root/passwd admin@192.168.204.130::common /tmp >/dev/null 2>&1 chmod 755 rsync.sh
在定时文件中写入定时执行任务,实例如下: * * * * * /home/rsync.sh 每分钟执行一次同步脚本; 0 * * * * /home/rsync.sh 每小时执行一次同步脚本; 0 0 * * * /home/rsync.sh 每天零点执行一次同步脚本; 0 9,18 * * * /home/rsync.sh 每天的9AM和6PM执行一次同步脚本;
列举整个同步目录或指定目录: rsync 10.0.0.12 :: rsync 10.0.0.12 :: www / 下载文件或目录到本地: rsync – avz 10.0.0.12 :: WWW/ /var/tmp rsync – avz 10.0.0.12 :: www/ /var/tmp 上传本地文件到服务端: rsync -avz webshell 10.0.0.12 :: WWW /
centos7安装配置rsync https://blog.51cto.com/12173069/2069243
日常运维--rsync同步工具 https://my.oschina.net/ccLlinux/blog/1859116
linux下匿名方式通过rsync同步文件 http://ju.outofmemory.cn/entry/42150
Linux下rsync的安装及简单使用 https://blog.51cto.com/13917261/2285348?source=dra
CentOS 7安装部署Rsync数据同步服务器 https://www.linuxidc.com/Linux/2017-06/144757.htm
-v, --verbose 详细模式输出
评论已关闭