Use rsync to synchronize network backup page 1/2

Source: Internet
Author: User
Tags rsync

I. Introduction
Rsync is a common backup tool, which is currently maintained by rsync.samba.org.
Rsync uses the so-called "rsync Algorithm ", Provides a very fast file transfer method to synchronize the files between the local and remote hosts. It is mainly used to transfer the changes of the two files, instead of transmitting the entire copy each time, the speed is quite fast.
Rsync can be used with RSH or SSH, or as a direct socket connection in daemon mode. Therefore, rsync can be used as an excellent backup tool.
I will briefly introduce the basic method for backing up remote network host files using rsync.
Here, we use rsync as a daemon mode for Linux.
First, let's give a simple definition: Of course, if you want a host to run the rsync daemon mode, we will call this machine an rsync server, or this host is a backup server ).
The backup host will open a port 873 and wait for the peer rsync connection.
During connection, the rsync server checks whether the password is consistent. If the password is checked, the file transmission starts.
When the first connection is complete, the entire file will be transferred once, and only the parts of the change between the two files will be transferred the next time.
The preceding figure shows how the rsync client (remote network host to be backed up) and rsync server operate.
With the above method, we can also set up multiple backup hosts so that important files on the network hosts can be distributed to several hosts to spread risks.
Once the backup is complete, we can perform further storage operations on these backup hosts, such as using tar to compress the files into the hard disk.
I used Ubuntu 7.10 As the client and centos5 as the server for testing.
Ii. Installation Method
The latest version of rsync is 2.6.8. You can download it from rsync.samba.org.
If you use the RPM suite, use the following method to install it. Of course, rhel5 and centos5 are installed by default.
# Rpm-IVH rsync *. rpm
# Yum install rsync
Its configuration file is located at/etc/rsyncd. conf. It is strange that my file is not automatically generated, so we will configure it ourselves.
3. Set rsync server: (assuming the host name is rsync.x111.com)
Set the following four items on the rsync server:
1. plan to create a backup directory
2. Start rsync in Xinetd
3. Setting:/etc/rsyncd. conf
4. Set: Password
The descriptions are as follows:
1. plan to create a backup directory:
We recommend that you prepare a large and independent partition and open the Backup Directory in it, so/blackup/x99
2. Start rsync in Xinetd
Xinetd is not installed by default.
# Yum install xinetd
# Service xinetd restart
# Chkconfig rsync on
The preceding operations mainly enable the rsync daemon. Once an rsync client is connected, xinetd will forward it to rsyncd (Port 873 ).
3. Set/etc/rsyncd. conf:
Global settings
Uid = root
Gid = root
Use chroot = No # Do not use chroot
Max connections = 4 # the maximum number of connections is 4
PID file =/var/run/rsyncd. PID
Lock file =/var/run/rsync. Lock
Log File =/var/log/rsyncd. log # log record file
The following section indicates the setting that is open to an rsync client host. The simple example is as follows:
[X99]
Path =/blackup/x99/x99_backup
Auth users = x99_backup
Secrets file =/etc/rsyncd. Secrets
Read Only = No
Annotations for the above files:
[X99] indicates the host code to be backed up. Set the host name by yourself.
PATH is used to set the directory where the backup file is to be stored. mkdir must be enabled first, and you can set it yourself.
Auth users indicates the authorized account, which can be set by yourself.
Secrets file indicates the password file for storing the account and password.
Of course, this backup host can accommodate many rsync client connections. You only need to set multiple parts in rsyncd. conf.
The following example indicates that the x99 and x100 hosts are to be backed up:
[X99]
Path =/blackup/x99/x99_backup
Comment = XXXXX
Auth users = x99_backup
Secrets file =/etc/rsyncd. Secrets
Read Only = No
[X100]
Path =/blackup/x100/x100_backup
Auth users = x100_backup
Secrets file =/etc/rsyncd. Secrets
Read Only = No
4. Set the password file:
The content of rsyncd. Secrets is easy, in the format of "account: Password ";
For example:
X99_backup: x99pass
Note! The preceding settings are just an example. You must never apply them directly.
Next, set the archive attribute of the rsyncd. Secrets password file to root and set the permission to 600. Otherwise, the backup will fail!
Therefore, see:
# Chown root. Root rsyncd. Secrets
# Chmod 600 rsyncd. Secrets
Now, the rsync server has been set up. To view the backup log.
# Tail-F/var/log/rsyncd. Log
Next is the setting of the client (that is, the network host to be backed up.

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.