rsync是linux系统下的数据备份同步工具,可以镜像保存整个目录树和文件系统;也支持增量备份(这个算法只传送两个文件的不同部分),保持原来文件的权限、时间、软硬链接等附加信息 负责发起rsync同步操作的客户机称为发起端,而负责响应来自客户机的为同步源。再同步过程中,同步源负责提供文档的原始位置,而发起端对该位置具有读取权限,最后同步到本地

系统:centos7.5 ##注释

#systemctl stop firewalld --关闭防火墙

#yum -y install rsync 2. #useradd -s /sbin/nologin -M rsync #id rsync uid=1000(rsync) gid=1000(rsync) 组=1000(rsync) 3. #vim /etc/rsyncd.conf uid = rsync gid = rsync use chroot = yes auth users = leshan pid file = /var/run/rsyncd.pid log file = /var/log/rsyncd.log secrets file = /etc/rsyncpw hosts allow = 10.41.104.0/24 #exclude = lost+found/ transfer logging = yes max connections = 1 timeout = 900 ignore nonreadable = yes dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

[backup] path = /root/backup
comment = backup test read only = no list = false

4.密码文件 #echo "leshan:123" > /etc/rsyncpw #cat /etc/rsyncpw leshan:123 #chmod 600 /etc/rsyncpw #ll /etc/rsyncpw
-rw------- 1 root root 11 8月 31 11:04 /etc/rsyncpw

5.启动服务 #systemctl restart rsyncd.service ## 很多人用这个rsync --daemon #netstat -ntlp | grep rsync
#lsof -i:873 ##rsync的端口为873

6.配置 rsync 客户端(密码) #rsync -av leshan@10.41.104.5::backup /root/rsync Password: 。。。。。。 5.1 免密 #echo "123" > /etc/rsyncpw ##只要密码就行,密码文件放在哪里都行 #cat /etc/rsyncpw 123 #chmod 600 /etc/rsyncpw #rsync -avz --delete --password-file=/etc/rsyncpw leshan@10.41.104.5::backup /root/rsync ##这样就不用输入密码,用crontab自动备份很是方便;

#rsync -v 10.41.104.5:: ##查看rsync服务器同步路径名