Rysnc is a data image and backup tool. files with local and remote hosts. between directories. quickly synchronize images. remote Data Backup and other functions. during synchronization. rsync is based on its own unique algorithm. only the changed files are synchronized. only the changed parts are synchronized in a file. so we can achieve fast data synchronization .. for more information, see download rys from wiki1.
Rysnc is a data image and backup tool. files with local and remote hosts. between directories. quickly synchronize images. remote Data Backup and other functions. during synchronization. rsync is based on its own unique algorithm. only the changed files are synchronized. only the changed parts are synchronized in a file. so we can achieve fast data synchronization .. for more information, see the official wiki.
1. Download The ryscn source code package and install the software.
Rsync-3.0.8.tar.gz
# Tar xvf rsync-3.0.8.tar.gz
# Cd rsync-3.0.8
#./Configure -- prefix =/usr
# Make &, make install
2. Configure rsync and create rsync. There are three configuration file files:
Rsyncd. conf is the main configuration file of rsync.
Rsyncd. motd indicates the rsync client. before copying a file, some prompts are returned.
Rsyncd. secrets: Create a password file for rsync.
# Mkdir/etc/rsyncd
# Cd/etc/rsyncd
# Touch rsyncd. conf
# Touch rsyncd. motd
# Touch rsyncd. secrets
3. rsync should be managed by the super daemon xinetd. First, modify the configuration file in the super daemon and then restart xinetd.
Change disable = yes
Disable = no
4. Configure the main configuration file for rsync
# Cd/etc/rsyncd
# Vim rsyncd. conf
Uid = nobody
Gid = nobody
Use chroot = yes
Read only = yes
Address = 192.168.3.143
Port = 873
Max connections = 5
Timeout = 300
Motd file =/etc/rsyncd. motd
Pid file =/var/run/rsyncd. pid
Log file =/var/log/rsyncd. log
Lock file =/var/run/rsyncd. lock
Hosts allow = 192.168.3.139
Hosts deny = *
Transfer logging = yes
Secrets file =/etc/rsyncd. secrets
# Auth users = root
List = yes
[Home]
Path =/root/test
Comment = product server home
Exclude = EtnetChinaUI/public
[Frank]
Path =/home/Frank
Comment = product server www
Exclude = logs/
Note: auth users is a real system user on the server. If you want to use multiple users, you can use the number to separate them.
For example, auth users = Frank, sanday
5. Modify rsyncd. secrets
Each line in this file is the corresponding user name and password. The format is as follows:
Username: password
# Chmod 600 rsyncd. secrets
Note: 1 to ensure security, the file attribute must be a read-only file.
2. For the sake of security, the password of the new system user cannot be written into the real password of the user in the system.
6. Configure the rsyncd. motd File
This file defines the information of the rsync server, that is, the user's login information. Of course, this file is not required either.
7. Explanation of the main configuration file of rsync
A global definition
# Note: the user and user group used by the server to transfer files. The default value is nobody. When the Default User and user group are used, the server may encounter permission issues, of course, you can also specify the root user to solve the permission problem.
Uid = nobody
Gid = nobody
# Note: With chroot, before transferring files, the server daemon sends chroot to the directory in the file system. This may protect the system from security vulnerabilities, the disadvantage is that Super User Permissions are required. in addition, the symbolic connection file will be excluded. that is, on the rsnc server. if you use a symbol to connect. when synchronizing data from a client running on the backup server, only the name of the symbolic connection is synchronized, and the symbolic connection to my content is not synchronized.
Use chroot = yes
# Note: read-only is read-only.
Read only = yes
# Specify the IP address of the server
Address = 192.168.3.143
# Define the port for rsync operation. The default value is 873.
Port = 873
# Set the maximum number of client connections
Max connections = 5
# Set the client connection timeout
Timeout = 300
# Note: The motd file defines the information on the server. You need to uninstall the content of the rsyncd. motd file. This information is displayed when you log on.
Motd file =/etc/rsyncd. motd
# Rsync process File
Pid file =/var/run/rsyncd. pid
# Rsync log files
Log file =/var/log/rsyncd. log
# Rsync lock file to prevent multiple rsync startup
Lock file =/var/run/rsyncd. lock
# Note: rsync file transfer logs
Transfer logging = yes
# Set the allowed clients
Hosts allow = 192.168.3.139
# Set an Unsupported client
Hosts deny = *
# User Password File
Secrets file =/etc/rsyncd. secrets
# Auth users = root
List = yes
Module B
This section mainly defines which directory file is to be synchronized in the system, and each module must be in the form of [Filename]. The defined name is the name seen on the rsync client, this is similar to samba. the data to be synchronized to the server is specified through path. you must specify the authentication user and password file for each module.
# The module provides a connection name for it.
[Home]
# Specify the location of the file directory, which must be specified
Path =/root/test
# The authenticated user is root and must exist on the server
Auth users = root
# List indicates whether to display the directory that provides synchronization data on the rsync server in the module on the server. The default value is yes. If it is for security, you can set it to no.
List = yes
# Annotations can be defined by yourself
Comment = product server home
# Password File
Secrets file =/etc/rsyncd. secrets
# Exclude is excluded from the EtnetChinaUI/public file under the/root/test directory. Of course, to exclude multiple directories, separate them with spaces in multiple directories.
Exclude = EtnetChinaUI/public
[Frank]
Path =/home/Frank
Comment = product server www
Exclude = logs/
8. Start the rsync service.
First, check whether iptables is disabled. If iptables is not disabled, disable iptables first. Of course, you can also add related firewall rules in iptables.
#/Usr/bin/rsync-daemon-config =/etc/rsyncd. conf