| 关键词: rsync 文件 rsyncd file 同步 secrets 服务器 root etc garbagekrc |
1、什么是rsyncrsync,remote synchronize顾名思意就知道它是一款实现远程同步功能的软件,它在同步文件的同时,可以保持原来文件的权限、时间、软硬链接等附加信息。 rsync是用“rsync 算法”提供了一个客户机和远程文件服务器的文件同步的快速方法,而且可以通过ssh方式来传输文件,这样其保密性也非常好,另外它还是免费的软件。 rsync 包括如下的一些特性: 能更新整个目录和树和文件系统; 有选择性的保持符号链链、硬链接、文件属于、权限、设备以及时间等; 对于安装来说,无任何特殊权限要求; 对于多个文件来说,内部流水线减少文件等待的延时; 能用rsh、ssh 或直接端口做为传输入端口; 支持匿名rsync 同步文件,是理想的镜像工具;2、rsync的安装,通用方式:yum install rsync3、rsync服务器的配置文件cat /etc/rsyncd/rsync.conf # Distributed under the terms of the GNU General Public License v2 # Minimal configuration file for rsync daemon # See rsync(1) and rsyncd.conf(5) man pages for help # This line is required by the /etc/init.d/rsyncd script pid file = /var/run/rsync.pid port = 873 #address = 192.168.1.171 #uid = nobody #gid = nobody uid = root gid = root use chroot = yes read only = no #limit access to private LANs hosts allow=* #hosts deny=* max connections = 5 motd file = /etc/rsyncd/rsync.motd #This will give you a separate log file #log file = /var/log/rsync.log #This will log every file transferred - up to 85,000+ per user, per sync #transfer logging = yes log format = %t %a %m %f %b syslog facility = local3 timeout = 300 [data] path = /data1 list=yes ignore errors auth users = root secrets file = /etc/rsyncd/rsync.secrets comment = rsync data1 dir #exclude = beinan/ samba/ [garbagekrc] path = /data1/garbagekrc list=yes ignore errors auth users = root secrets file = /etc/rsyncd/rsync.secrets comment = rsync garbagekrc dir用户密码文件:cat /etc/rsyncd/rsync.secrets root:test123其中用户名必须是服务器上已经存在的用户4、启动rsync服务:/usr/bin/rsync --daemon --config=/etc/rsyncd/rsync.conf5、备份文件到服务器:rsync -az --password-file=rsync.password jsoncpp/* root@IP::data/mydata/其中:password-file可以指定密码。6、rsync也可以从服务器上拉文件到本地。结合crontab可以实现定时同步的功能。7、更多用法请:man rsync。 |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|