Installation and configuration of linux rsync

Source: Internet
Author: User
Tags rsync

1. Installation: yum-y install rsync

2. vim/etc/xinetd. d/rsync

Copy codeThe Code is as follows: service rsync
{
Disable = no
Socket_type = stream
Wait = no
User = root
Server =/usr/bin/rsync
Server_args =-daemon
Log_on_failure + = USERID
}

3. vim/etc/rsyncd. conf (this file is manually created and does not exist by default)

Uid = nobody # ID of the backup, user ID
Gid = nobody # ID of the backup, group ID
# Note that this user ID and group ID can be set to root for convenience, so rsync is almost ready.
# To read any files and directories, but it also brings security risks. We recommend that you set it to read only the directories and files you want to back up.
.

Use chroot = no
Max connections = 0 # maximum number of connections, 0 indicates no limit
# Port = 873 # default port 873
Pid file =/var/log/rsync/rsyncd. pid # Where to write the ID of the running process
Lock file =/var/log/rsync. lock
Log file =/var/log/rsync/rsyncd. log # log record file
Motd file =/var/log/rsync/rsyncd. motd # Welcome Message
Strict modes = yes # Check the permission of the password file
[Www] # specify the name of the authenticated backup module
Uid = www1
Gid = www1
Path =/www/# directory to be backed up
Comment = BACKUP attachment # comment
Ignore errors # ignore unrelated IO errors
Read only = false # It is set to non-read-only, that is, it can be passed to the corresponding directory of the server.
List = false # column Files Not Allowed
# Exclude = test/test. php # Set non-synchronous directories or files to be separated by Spaces
Hosts allow = all # ip addresses of hosts allowed to connect to the server. Separate multiple ip addresses with spaces.
Hosts deny = 172.25.0.0/24 # the IP address of the host that disconnects to the server. The IP address can also be *, indicating all.
Auth users = backup # The authenticated user name. If this row is not used, it indicates that it is anonymous.
Secrets file =/etc/rsyncd. passwd # authentication file name, used to store the password
[Www1]
Path =/www1/
Ignore errors
Read only = true
List = false
Hosts allow = 202.99.11.121
Hosts deny = 0.0.0.0/32
Auth users = backup
Secrets file =/etc/rsyncd. passwd

4./etc/rsyncd. passwd is the file that saves user account information.
Format: backup: password. The permission must be 600

5. Service restart:/usr/bin/rsync-daemon-config =/etc/rsyncd. conf

6. Client synchronization:
Rsync-vzrtopg-delete-progress backup@192.168.18.200: www1/backup/www1-password-file =/etc/rsyncd. password

7. Schedule Tasks
Vim/opt/rsyncd. sh
Rsync-vzrtopg-delete-progress backup@192.168.18.200: www1/backup/www1-password-file =/etc/rsyncd. password
Chmod u + x/opt/rsyncd. sh
Crontab-e
0 5 *** sh/opt/rsyncd. sh # synchronize once every 5 hours

The following is a supplement:

Installation System: redhat linux as 4 2.6.9
Rsync is a data image backup tool in unix-like systems. It can be seen from the software name-remote sync. Its features are as follows:
Images can be used to save the entire directory tree and file system.
It is easy to maintain the permissions, time, and soft links of the original file.
Installation without special permissions.
Optimized process, high file transmission efficiency.
You can use rcp, ssh, and other methods to transmit files. Of course, you can also use a direct socket connection.
Supports anonymous transmission for website images.
Step
1. Download from the original Website: [url] http://rsync.samba.org/ftp/rsync/#/url]
2. [root @ localhost bin] #./configure
[Root @ localhost bin] # make
[Root @ localhost bin] # make install
Note that rsync must be installed on both the client and server. The client runs rsync as a client, and the server runs rsync as a server. It listens to port 873.
3. Run rsync
/Usr/local/bin/rsync -- daemon
Verify that the startup is successful:
Netstat-na | grep 873
4. Configure rsync
Simple configuration: edit the/etc/rsyncd. conf file as follows:
# Global configuration
Secrets file =/etc/rsyncd. secrets name and location of the authenticated user name and password file
Motd file =/etc/rsyncd. motd welcome information file name and storage location (this file does not exist, you can add it yourself)
Read only = yes
List = yes
Uid = root
Gid = root
# Hosts allow = 10.4.5.213
# Hosts deny = 10.4.5.0/24
Use chroot = no
Max connections = 5
Log file =/var/log/rsyncd. log
Pid file =/var/run/rsyncd. pid
Lock file =/var/run/rsync. lock
# Module configuration
[Web]
Comment = web's directory
Path =/home/test/software
Auth users = rsync
# Secrets file =/etc/rsyncd. secrets
5. Generate verification documents
Echo "rsync: rsync_password">/etc/rsyncd. secrets
Chmod 600/etc/rsyncd. secrets
6. Synchronize files on the server on the client server
Rsync-vzrtopg -- delete -- progress rsync@10.4.5.161: web/china/
Or add the -- password-file =/etc/rsyncd. secrets option.
The preceding command transfers the directory files in the web module on the 10.4.5.161 server to the local/china directory, and deletes the files not in the directory specified by the web module on the 161 server in the local/china directory. To synchronize the directory files of the two computers.

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.