您现在的位置: 万盛学电脑网 >> 电脑基础 >> 电脑基本常识 >> 正文

windows下安装和配置rsync(cwRsync)

作者:佚名    责任编辑:admin    更新时间:2022-06-22

   第一步我们先安装服务端:

  下载完西西提供的整合包,里面有一个服务器的安装程序和一个绿色的客户端

windows下安装和配置rsync(cwRsync) 三联

  我们先双击 cwRsyncServer_4.1.0_Installer.exe 来安装

  到这一步的时候,他会提示您帮你新建一个用于同步的 Rsync的系统账号,当然你也可以自定义用户名和密码。

  安装完成后rsync会加载以服务的方式来运行。

  在 windows的服务中我们可以看到一个 RsyncServer 的服务,安装后他默认是停止的您可以手动启动,最好把启动类型设为 自动 这样下次如果服务器重启这个软件也会自动启动了。

  我们现在来说一下如何配置服务器文件。 在您的安装目录下可以找到一个 rsyncd.conf 的配置文件,这个文件和linux下面一样,您也可以在开始菜单中找到这个文件的链接

  我们先来配置一下:

  use chroot = false

  strict modes = false

  lock file = rsyncd.lock

  hosts allow = 192.168.1.21

  max connections = 5port = 28950

  gid = 0

  uid = 0

  log file = /cygdrive/f/RsyncLog/rsyncd.log# Module definitions

  # Remember cygwin naming conventions : c:work becomes /cygdrive/c/work

  [cr173com]

  path = /cygdrive/d/cr173/

  secrets file = /cygdrive/e/Setting/Rsync/rsync_db.PS

  read only = no

  list = no

  transfer logging = yes

  以上配置只允许192.168.1.21 访问,这里按需修改。 如果需要添加多个IP 单个IP地址,例如:192.167.1.1 整个网段,例如:192.168.1.0/24,也可以是192.168.1.0/255.255.255.0

  多个IP或网段需要用空格隔开,“*”则表示所有,默认是允许所有主机连接。

  strict modes = false 不验证用户密码,

  pid = 0,uid = 0 指定匿名访问。

  auth users 指访问data_backup的用户名

  secrets file data_backup用户名对应的密码文件。

  path:指定同步的文件目录

  use chroot:如果"use chroot"指定为true,那么rsync在传输文件以前首先chroot到path参数所指定的目 录下。这样做的原因是实现额外的安全防护,但是缺点是需要以roots权限,并且不能备份指向外部的符号连接所指向的目录文件。默认情况下chroot值为true。

  numeric ids

  munge symlinks

  charset

  max connections:指定该模块的最大并发连接数量以保护服务器,超过限制的连接请求将被告知随后再试。默认值是0,也就是没有限制。

  log file:指定rsync的日志文件

  syslog facility:是否使用系统日志工具。可以有如下选项:

  auth, authpriv, cron, daemon, ftp, kern, lpr, mail, news, security, syslog, user, uucp, local0, local1, local2, local3, local4, local5, local6 and local7. The default is daemon.

  max verbosity

  lock file:指定支持max connections参数的锁文件

  read only:该选项设定是否允许客户上载文件。如果为true那么任何上载请求都会失败,如果为false并且服务器目录读写权限允许那么上载是允许的。默认值为true。

  write only:该选项设定是否允许客户下载文件。如果为true那么任何下载请求都会失败,如果为false并且服务器目录读写权限允许那么下载是允许的。默认值为true。

  list:该选项设定当客户请求可以使用的模块列表时,该模块是否应该被列出。如果设置该选项为false,可以创建隐藏的模块。默认值是true。

  uid:指定传送数据的帐号,仅仅用于指定模块。默认是:-2 ,即Nobody 帐号.

  gid:指定传送数据的帐号组,仅仅用于指定模块。默认是:-2 ,即Nobody 组.

  fake super

  filter

  exclude:用来指定多个由空格隔开的多个文件或目录(相对路径),并将其添加到exclude列表中。这等同于在客户端命令中使用--exclude来指定模式,一个模块只能指定一个exclude选项。但是需要注意的一点是该选项有一定的安全性问题,客户很有可能绕过exclude列表,如果希望确保特定的文件不能被访问,那就最好结合uid/gid选项一起使用。

  include:用来指定不排除符合要求的文件或目录。这等同于在客户端命令中使用--include来指定模式,结合include和exclude可以定义复杂的exclude/include规则。

  exclude from:指定一个包含exclude模式的定义的文件名,服务器从该文件中读取exclude列表定义。

  include from:指定一个包含include模式的定义的文件名,服务器从该文件中读取include列表定义。

  incoming chmod:

  outgoing chmod

  auth users:设置连接指定模块的授权用户名。

  secrets file:密码认证文件,格式为:username:password

  strict modes:该选项指定是否监测密码文件的权限,如果该选项值为true那么密码文件只能被rsync服务器运行身份的用户访问,其他任何用户不可以访问该文件。默认值为true。

  hosts allow:该选项指定哪些IP的客户允许连接该模块。客户模式定义可以是以下形式:

  单个IP地址,例如:192.167.1.1

  整个网段,例如:192.168.1.0/24,也可以是192.168.1.0/255.255.255.0

  多个IP或网段需要用空格隔开,“*”则表示所有,默认是允许所有主机连接。

  hosts deny:指定不允许连接rsync服务器的机器,可以使用hosts allow的定义方式来进行定义。默认是没有hosts deny定义。

  ignore errors:指定rsyncd在判断是否运行传输时的删除操作时忽略server上的IO错误,一般来说rsync在出现IO错误时将将跳过--delete操作,以防止因为暂时的资源不足或其它IO错误导致的严重问题。

  ignore nonreadable:指定rysnc服务器完全忽略那些用户没有访问权限的文件。这对于在需要备份的目录中有些文件是不应该被备份者得到的情况是有意义的。

  transfer logging:使rsync服务器使用ftp格式的文件来记录下载和上载操作在自己单独的日志中。

  log format:通过该选项用户在使用transfer logging可以自己定制日志文件的字段。

  #The single-character escapes that are understood are as follows:

  #%a the remote IP address

  #%b the number of bytes actually transferred

  #%B the permission bits of the file (e.g. rwxrwxrwt)

  #%c the total size of the block checksums received for the basis file (only when sending)

  #%f the filename (long form on sender; no trailing "/")

  #%G the gid of the file (decimal) or "DEFAULT"

  #%h the remote host name

  #%i an itemized list of what is being updated

  #%l the length of the file in bytes

  #%L the string " -> SYMLINK", " => HARDLINK", or "" (where SYMLINK or HARDLINK is a filename)

  #%m the module name

  #%M the last-modified time of the file

  #%n the filename (short form; trailing "/" on dir)

  #%o the operation, which is "send", "recv", or "del." (the latter includes the trailing period)

  #%p the process ID of this rsync session

  #%P the module path

  #%t the current date time

  #%u the authenticated username or an empty string

  #%U the uid of the file (decimal)

  #For a list of what the characters mean that are output by "%i", see the --itemize-changes option in the rsync manpage.

  timeout:该选项可以覆盖客户指定的IP超时时间。通过该选项可以确保rsync服务器不会永远等待一个崩溃的客户端。超时单位为秒钟,0表示没有超时定义,这也是默认值。对于匿名rsync服务器来说,一个理想的数字是600。

  refuse options:通过该选项可以定义一些不允许客户对该模块使用的命令参数列表。这里必须使用命令全名,而不能是简称。但发生拒绝某个命令的情况时服务器将报告错误信息然后退出。如果要防止使用压缩,应该是:"dont compress = *"