Rsync remote backup installation settings

Source: Internet
Author: User
Tags rsync usage

RSYNC software introduction:
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.
Rsync must be installed on both server A and server B, where server A runs rsync in server mode, while server B runs rsync in client mode. In this way, on web server

Run the rsync daemon and regularly run the client program on server B to back up the content to be backed up on server A. Therefore, two virtual machines are available in this article.

The IP address is 10.0.0.10 as the server.

The IP address is 10.0.0.12 as the client.

===== Server Installation configuration ======

1. Install rsync

Yum install rsync-y

2. vi/etc/xinetd. d/rsync

Change the original YES to NO.

Service rsync
{
Disable = no
Socket_type = stream
Wait = no
User = root
Server =/usr/bin/rsync
Server_args = -- daemon
Log_on_failure + = USERID

}

3. Start RSYNC with the System

Chkconfig rsync on

4. Configure/etc/rsyncd. conf (manually generated)

The parameters of rsyncd. conf are written on the top as global parameters, and the parameters of modules are written on the top.

Vi/etc/rsyncd. conf

# Global Parameters

Uid = root // the user who runs the RSYNC daemon

Gid = root // the group that runs the RSYNC daemon

Use chroot = no // do not use chroot

Max connections = 45 // The maximum number of connections is 5

Strict modes = yes // check the permission of the password file

Port = 873 // default port 873

# Module Parameters

[Backup] // The Authentication Module name. You must specify

Path =/web // The Directory of the image to be created, which is indispensable!

Comment = backup for web // comments of this module

Ignore errors // ignore irrelevant IO errors

Read only = yes // read-only

List = no // column files are not allowed

Auth users = gao // The authenticated user name. If this row is not used, it indicates that the user is anonymous and has nothing to do with the system.

Secrets file =/etc/rsync. pas // table of password and user name comparison. The password file is generated by yourself.

Hosts allow = 10.0.0.12 // host is allowed. Only IP addresses and domain names are allowed.

Hosts deny = 0.0.0.0/0 // disable host

# Transfer logging = yes

# Note: The following green files are automatically generated after the RSYNC service is installed.

Pid file =/var/run/rsyncd. pid // storage location of the pid file

Lock file =/var/run/rsync. lock // location of the lock file

Log file =/var/log/rsyncd. log // location where the log file is stored

5. Configure the rsync password (the path has been written in the above configuration file)/etc/rsync. pas (name can be written at will, as long as it is consistent with the above configuration file), format (one row per user)

Account: Password

Vi/etc/rsync. pas

Join:

Rsync: 123456

6. Permission: Because rsync. pas stores the user name and password of the rsync service, it is very important. Set rsync. pas to be owned by the root user and the permission is 600.

Cd/etc

Chown root. root rsync. pas

Chmod 600 rsync. pas

Chmod 600 rsyncd. conf

8. Make the configuration take effect

Service xinetd restart

9. Start rsync server

RSYNC server startup

/Usr/bin/rsync rsyncd -- daemon

10. Add rc. local

In various operating systems, rc files are stored in different locations and can be modified so that rsync-daemon can be loaded during system startup.

Vi/etc/rc. local

Add/usr/bin/rsync rsyncd -- daemon

11. Check rsync

Netstat-a | grep rsync

======= Client installation configuration ========

1. Install rsync

Yum install rsync-y

1. Set the password

Vi/etc/rsync. pas

123456

2. Modify permissions

Cd/etc

Chown root. root rsync. pas

Chmod 600 rsync. pas

3. Connect the client to the SERVER

Retrieving files from the SERVER

Rsync-vzrtopg -- progress-delete rsync@10.0.0.10: backup/web -- password-file =/etc/rsync. pas

#4. upload files to the SERVER (this step does not need to be executed. If executed, modify the parameters of the/etc/rsyncd. conf file of the previous host)

# Rsync-vzrtopg -- progress -- password-file =/etc/rsync. pas/backup/web/rsync@10.0.0.10: backup

This command backs up all files (including subdirectories) in the local machine/web directory to the backup directory set by the backup module of rsync server (10.0.0.10.

Note that if the path ends with "/", it indicates backing up the stuff in the directory, but it does not create this directory. If it does not contain "/", it is created.

RSYNC usage:

Rsync [OPTION]... [USER @] HOST: SRC [DEST] # Back Up Files from rsync server to Local Machine

Rsync [OPTION]... SRC [SRC]... [USER @] HOST: DEST # Back Up Files from local machines to RSYNC SERVER

5. Automatic Operation

1) vi/backup/rsync. sh // create a script file

Copy the following content

#! /Bin/bash

Rsync-vzrtopg -- progress -- deletegao@10.0.0.10: backup/web/-- password-file =/etc/rsync. pas

2) grant the execution permission to the/backup/rsync. sh File

Chmod 744/backup/rsync. sh

3) execute/backup/rsync. sh text

./Backup/rsync. sh

6. crontab-e

Add 0 12 ***/backup/rsync. sh // run the rsync. sh script file once every 12 o'clock.

7. Start the rsync service:

/Usr/bin/rsync -- daemon

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.