Quickly build an efficient Rsync service using Shell scripts

Source: Internet
Author: User

During our daily O & M, we often encounter the need to set up the rsync service, such as website file synchronization (image or backup), patch update, disaster Tolerance and backup for various different machine backups. If you write the rsync service as a script, you can have a basic service framework after the script is executed. You only need to further improve the details and security requirements, this improves our work efficiency.

Many Linux systems, such as RHEL and CentOS, are installed with rsync 2 by default. version x, and I recommend 3. version x, because 3. x improves the synchronization algorithm to make it more efficient.

Rsync Official Website: http://rsync.samba.org/

1) download the latest stable version of rsync-3.0.8
[Root @ server ~] # Cd tools
[Root @ server tools] # wget-chttp: // rsync.samba.org/ftp/rsync/src/rsync-3.0.8.tar.gz
2) Compile and install rsync-3.0.8
[Root @ servertools] # tar xf rsync-3.0.8.tar.gz
[Root @ server tools] # cd rsync-3.0.8
[Root @ server rsync-3.0.8] #./configure & make
3) after compilation and installation, it will generate the rsync binary file in the rsync-3.0.8/directory, copy it to/usr/local/bin:
[Root @ server rsync-3.0.8] # \ cp rsync/usr/local/bin

PS: both the server and the client must perform the above installation operations. If both the client and the server are a type of operating system, you can compile and install it once, then, the rsync BINARY command is distributed to/usr/local/bin/of other servers.

4) edit the Rsync service build script (rsync_server_set.sh) on the server)
[Root @ server] # cd shells/
[Root @ server shells] # vi rsync_server_set.sh

#! /Bin/bash
#
# Script Name: rsync_server_set.sh
# Description: set rsync service quickly.
# + ------------------ Client side e.g. ------------------ +
# $ Rsync-avz/root/admin/xxx.txt $ address: mystation
# $ Rsync-avz $ address: xxx_client // home/
# + ------------------------------------------------------ +
# Author: 300 second-51cto.com
# Date: 2012-10-18
#

Rsync =/usr/local/bin/rsync
Conf_file =/etc/rsyncd. conf
Port = 873
Address = 192.168.1.41
Hosts_allow = 192.168.1.0/24
Rsync_dir ='
[Mystation]
Path =/home/admin/

'
Date = 'date + % F "" % t'

Cat> $ conf_file <EOF
Pid file =/var/run/rsyncd. pid
Port = $ port
Address = $ address
Uid = root
Gid = root
Use chroot = no
Read only = no
Hosts allow = $ hosts_allow
# Hosts deny = *

$ Rsync_dir

EOF

$ Rsync -- daemon -- config = $ conf_file

Cat>/etc/rc. local <EOF
# Rsync daemon $ date
$ Rsync -- daemon -- config = $ conf_file

EOF

Exit 0

5) run the script on the server to build the Rsync service.
[Root @ server shells] # chmod 755 rsync_server_set.sh
[Root @ server shells] #./rsync_server_set.sh

Related Article

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.