Using Rsync to implement file synchronization _win servers

Source: Internet
Author: User
Tags auth chmod join custom name file permissions port number rsync
rsync->>> Remote Synchronize
Oh, do not have to explain it, or explain it, the meaning of the document synchronization said ...

The first step is to download the free software first.

rsync.samba.org/or Samba.anu.edu.au/rsync.
The latest version of this site download the address
Http://www.jb51.net/softs/2149.html
PS: Must go to the official website to download the latest version,
Because the previous version of 2.6.1 has a configuration module path through the vulnerability ...

After decompression, the compilation is simple
./configure–prefix=/usr/local/rsync && make && make install

And then we'll configure the server.

To edit the server-side configuration file first

#vi/etc/rsyncd.conf

#全局配置
UID = root
GID = root
Hosts allow = 192.168.0.0/24
#hosts deny = 0.0.0.0/32

Use chroot = no # chroot not used
Max connections = 10 # Maximum number of connections is 10
#motd file =/etc/rsyncd.motd #欢迎信息文件名称和存放位置 (this file is not available and can be added by itself)
PID file =/var/run/rsyncd.pid #指定rsync的pid文件
Lock file =/var/run/rsync.lock #指定支持max connections parameter, the default value is/var/run/rsyncd.lock
Log file =/var/log/rsyncd.log #指定rsync的日志文件, not sending logs to syslog

#下面就是每个模块的配置了
[Rsync_module_name1] # Here is the Certified module name, which needs to be specified on the client side
Path =/rsync_path/dir1 # A directory that needs to be mirrored
Comment = rsync files
Ignore errors # can ignore some irrelevant IO errors
Read Only = yes # reading only
List = no # does not allow column files
Auth users = rsync_user # authenticated username, if not, it indicates anonymity, multiple users, separated
Secrets file =/etc/rsyncd.pas # Certified file name
#pid file =/var/run/rsyncd.pid
#log file =/var/log/rsyncd.log
#lock file =/var/run/rsync.lock

[Rsync_module_name2]
......

Among them, the individual believes that no configuration can be both in the global configuration, can also be configured inside the module, if the module inside if there is the same configuration as the global,
The configuration inside the module overrides the global configuration.

Then edit the authentication file you specified above, I am here:/etc/rsyncd.pas

#vi/etc/rsyncd.pas
Format is: Username:password
Rsync_user:rsyncofpass

For security purposes, change the authentication file properties
#chmod 0600/etc/rsyncd.pas

OK, now start the next try it.

#/usr/local/rsync/bin/rsync–daemon
You can also specify the ports that Rsync runs
#/usr/local/rsync/bin/rsync–daemon–port=873

There are several different ways to start a service at startup, such as:

Join inetd.conf
Edit/etc/services, add rsync 873/tcp, specify the service port for Rsync is 873
Edit/etc/inetd.conf, join rsync stream TCP nowait root/bin/rsync Rsync–daemon

Join Rc.local

In a variety of operating systems, RC file storage location is not the same, you can modify the system to boot when the Rsync–daemon loaded in.

I'm here to join the/etc/rc.local directly.
/usr/local/rsync/bin/rsync–daemon–port=873
873 is the default port number for rsync.

Remember to configure the firewall to allow you to rsync ports TCP and UDP protocols.
873:tcp 873:UDP

The following starts configuring the client

The V in-VZRTOPG in the following command line is verbose,
Z is a compressed transmission,
R is recursive,
TOPG are the parameters that keep the original attributes of the file, such as the owner and the time.
You are only synchronizing the files that have been updated, so that files that are not updated are updated once, but be aware of the synchronization of both machines ' clocks.
–progress means showing detailed progress,
–delete means that if the server side deletes this file, then the client also deletes the file accordingly, maintaining true consistency.
Later in the rsync_user@192.168.0.2::rsync_module_name1, the rsync_module_name1 is the module name, which is the custom name in/etc/rsyncd.conf, rsync_ User is the username specified in the specified module that can be synchronized.
The last/TMP is the directory name that is backed up to the local.
In this case, you can also use the e-ssh parameter to establish an encrypted connection.
You can use –password-file=/password/path/file to specify a password file, so that it can be used in the script without having to enter the authentication password interactively, it should be noted that this password file permission attribute must be set to only the owner-readable.

#/usr/local/rsync/bin/rsync-vzrtopg–progress–delete rsync_user@192.168.0.2::rsync_module_name1/tmp/
Password:
Or you can make password files.
Because of the need for system crontab execution, here is the way to read the password file,
This is the time to succeed.

#vi/etc/rsyncd.pas
Join
Rsync_user:rsyncofpass
Note that the client's password file requires only a password and does not require a username!

Rsyncofpass

To change file permissions:
#chmod 0600/etc/rsyncd.pas

#/usr/local/rsync/bin/rsync-vzrtopgu–progress–delete–password-file=/etc/rsyncd.pas rsync_user@192.168.0.2:: rsync_module_name1/tmp/
Do not know why, always prompt the following authentication error
@ERROR: Auth failed on module rsync_module_name1
Rsync Error:error starting Client-server Protocol (code 5) at MAIN.C (1383) [receiver=2.6.9]
Depressed, how can be uncertain, but also want to have experienced friends to provide support ...

In today's client password file only entered the password, finally succeeded

Later have time to study the certification problem, time tight, task urgent, the verification first bypass.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.