Introduction
rsync (remote sync) is a Unix and Unix-like platform for data mirroring backup software, it does not require full backup as FTP, rsync can be based on the change of data for differential backup, thereby reducing data traffic, improve productivity
Rsync is mainly divided into three configuration files, rsyncd.conf (Master profile), Rsyncd.secrets (password file), RSYNCD.MOTD (server information file)
?
Environment
Centos7
Ip:192.168.10.130?? As an rsync server
Centos7
Ip:192.168.10.132? As an rsync client
?
server-side configuration steps
Rsync is installed by default in Centos7, and we begin to modify the configuration file directly.
# vim/etc/rsyncd.conf
Master configuration File Description
Vim/etc/rsyncd.conf
MOTD file =/etc/rsyncd.motd??? #设置服务器信息提示文件, write a message in the file
Transfer logging = yes??? #开启rsync数据传输日志功能
Log file =/var/log/rsyncd.log??? #设置日志文件名, log format can be set through the log format parameter
PID file =/var/run/rsyncd.log??? #设置rsync进程号保存文件名称
Lock file =/var/run/rsync.lock??? #设置锁文件名称
Port = 873??? #设置服务器监听的端口号, the default is 873
Address = 192.168.0.230??? #设置本服务器所监听网卡接口的ip地址
UID = nobody??? #设置进行数据传输时所使用的帐户名或ID号, nobody is used by default
GID = Nobody??? #设置进行数据传输时所使用的组名或GID号, nobody is used by default
#若为yes, Rsync starts with the chroot setting, which maps the root to the path of the following path parameter, and to the client, the root of the system is the path specified by the path parameter. However, this requires root permission and only synchronizes the name when synchronizing the symbol connection data, not synchronizing the content.
Use chroot = no?
Read Only = yes??? #是否允许客户端上传数据, yes indicates not allowed
Max Connections =10??? #设置并发连接数, 0 means no Limit
[Common]??? #自定义模块名, rsync defines a synchronized directory through a module, which defines multiple
Comment = Web content??? #定义注释说明字串
Path =/common??? #同步目录的真是路径通过path指定
Ignore errors??? #忽略一些IO错误
#exclude = test/??? #exclude指定common目录下某个目录可以不同步数据
Auth users = zzz??? #设置允许连接服务器的账户, this account can be a non-existent user in the system
Secrets file =/etc/rysncd_users.db??? #密码验证文件名, the file permission requirement is read-only, recommended as 600, only valid after setting auth users
Hosts allow = 192.168.0.0/255.255.255.0?? #设置哪些主机可以同步数据, use spaces between multiple IP and network segments
Hosts deny=*??? #除了hosts the host defined by allow, deny all other
List = False??? #客户端请求显示模块列表时, if the module name is displayed, the default is True
?
Firewall security Settings
#firewall-cmd--permanent--add-port=873/tcp??? #添加防火墙规则, allow 873-port data access
#setenforce 0
?
Installing the HTTP Service
# yum Install Httpd–y
Create a password file
#echo "zzz:123" >/etc/rsyncd_users.db
Securing Your Password Files
#chmod 600/etc/rsyncd_users.db
?
Open service
#rsync –daemon?? #--daemon for background execution, client open rsync does not require--daemon option
echo "/usr/bin/rsync--daemon" >>/etc/rc.local??? #开机启动rsync服务
?
Client Synchronization Data
Yum-y Install Rsync
RSYNC-VZRTOPG--progress [email protected]:: wwwroot/test???? #通wwwroot模块指定的目录下的文件拷贝到本客户端的 the/test directory
Parameter description
V: Show more information
Z: Compression of data during transfer
R: Recursive
T: Preserve modification Time Properties
O: Preserve file Owner Properties
P: Preserve file permission Properties
G: Preserve the group attributes that the file belongs to
A: Archive mode, main reserved file attributes, equivalent to-rlptgod
--progress: Show progress information for data transfer
--password-file=file: Specifies the password file, writes the password to the file, realizes the non-interactive data synchronization, this file name also needs to modify the permission to be 600
--delete: Delete files that exist only in the target path (not present in the source path), and data synchronization in the script often adds this parameter
--list-only: List of server modules only, requires Rsync server Setup List=true
Rsync file synchronization configuration in Linux under the detailed