[Original] Rsync build and use

Construction and use of rsync service

 

***Download and install:

#wget https://download.samba.org/pub/rsync/src/rsync-3.1.2.tar.gz

#tar -zxvf rsync-3.1.2.tar.gz

#cd rsync-3.1.2

#./configure --prefix=/usr/local/rsync

#make

#make install

 

Step 1: Modify the rsyncd configuration file and add the test directory test
#vim /etc/rsyncd.conf
uid = www-data
gid = www-data
use chroot = yes
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log


[test_code]
path = /data/www/html
comment = web resources
read only = no
strict modes = yes
refuse options = delete
auth users = test
secrets file = /etc/rsyncd_auto_rsync_users
hosts allow = xxx.xxx.xxx.xxx
post- xfer exec = /data/sa/reload_nginx.sh //Specify the script to trigger execution after synchronization is complete


[test]
path = /data/test
max connections = 5  //最大连接数
comment = test
read only = no
strict modes = yes
refuse options = delete  //拒绝删除操作
auth users = test
secrets file = /etc/rsyncd_auto_rsync_users
hosts allow = xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx
transfer logging = yes
log format = %t %o %a %m %u %f %l %b
log file = /var/log/rsyncd_test.log
post-xfer exec = /data/sa/reload_nginx.sh

 

Step 2: Modify the rsync password file and add the user and password of the pic_test module
root@localhost:/data/sa# cat /etc/rsyncd_auto_rsync_users
test:xxxxxxxxxxxxxx
test1:xxxxx

 

Step 3:
Restart the rsyncd service
/usr/bin/rsync --no-detach --daemon --config /etc/rsyncd.conf --port=873 &


Example of command synchronization:

Synchronize the test_code module file from the rsync server to the local, except the /home/huangjie1/pass_id.list directory:
rsync -avuzt --exclude-from '/home/huangjie1/pass_id.list' test@rsync_ip::test_code/* /data/www/html/

 

Extension: Generally, tools such as sersync, lrsync, and inotify-tools can automatically discover real-time synchronization files or two-way synchronization. Each has its own advantages and disadvantages. You can check the information yourself.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325220462&siteId=291194637