Ubuntu 14.04.2配置rsync

 ubuntu系统自带rsync,首先配置/etc/default/rsync,启用daemon模式

修改/etc/rsyncd.conf配置文件

cat /etc/rsyncd.conf 
# sample rsyncd.conf configuration file

# GLOBAL OPTIONS

#motd file=/etc/motd
 log file=/var/log/rsyncd
# for pid file, do not use /var/run/rsync.pid if
# you are going to run rsync out of the init.d script.
# The init.d script does its own pid file handling,
# so omit the "pid file" line completely in that case.
  pid file=/var/run/rsyncd.pid
  syslog facility=daemon
#socket options=

# MODULE OPTIONS

[image_ftp]

	comment = public archive#comment名称自定义
	path = /var/www/html#需要同步的目录
	use chroot = no
#	max connections=10
	lock file = /var/lock/rsyncd
# the default for read only is yes...
	read only = yes
	list = yes
	uid = root
	gid = root
#	exclude = 
#	exclude from = 
#	include =
#	include from =
 	auth users = root  #该用户需和客户端拉取用户保持一致,这里以root为例
 	secrets file = /etc/rsyncd.secrets  #用户密码文件
	strict modes = yes
	hosts allow = 192.168.1.100  #允许拉取的客户端ip
#	hosts deny =
	ignore errors = yes
	ignore nonreadable = yes
	transfer logging = yes
	log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
	timeout = 600
	refuse options = checksum dry-run
	dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz

 创建存放用户名和密码的文件

vim /etc/rsyncd.secrets

启动rsync服务

/etc/init.d/rsync start

  赋予600权限

chmod 600 /etc/rsyncd.secrets

查询服务是否启动,注意防火墙需要开放873端口

在客户端上执行拉取命令,nohup+& 让服务保持在后台运行,防止中断

nohup rsync -avuz -e 'ssh -p 2222' root@192.168.1.100:/var/www/html /data &
nohup rsync -avuz -e 'ssh -p 2222' root@192.168.1.100:/var/www/html /data
ctrl + z 挂起
bg 将进程置于后台运行
jobs 查询后台运行任务

  

原文地址:https://www.cnblogs.com/caidingyu/p/11205302.html