Quick configuration of Rsync file backup service in centos

Source: Internet
Author: User

Quick configuration of Rsync file backup service in centos

Rsync simple and quick Configuration

Rsync supports full and incremental local or remote data backup. An rsync is equivalent to scp, cp, rm, but better than each of their commands. Because rsync is such a useful software, many Linux releases include it.

Of course, you can also go to the official rysnc Website: http://rsync.samba.org/to get to the latest region.

The installation method is similar to the yum install rsync-y or get the gz package from the website for compilation and installation.

1. Configure the rsync server file.

By default, its configuration file does not exist. Therefore, you need to manually create a configuration file.

Touch/etc/rsyncd. conf

The file content is as follows:

# Rsync is connected by a client and has the default user permission settings

Uid = rsync

Gid = rsync

# Enable the default settings related to program security.

Use chroot = no

# Set the number of client connections.

Max connections = 2000

# Timeout time: the client has been connected to the server for more than 600 seconds to kill the connection.

Timeout = 600

# Pid file. pid is the process number.

Pid file =/var/run/rsyncd. pid

Lock file =/var/run/rsyncd. lock

Log file =/var/log/rsyncd. log

# Ignore errors

Ignore errors

# Set whether the read/write operation is normal. Currently, the read-only operation is false, so the result is read/write.

Read only = false

# Do not allow the server list.

List = false

# Ip addresses allowed.

Hosts allow = 192.0.0.0/24

# Rejected IP addresses

Hosts deny = 0.0.0.0/32

# Enable a virtual user.

Auth users = rsync_backup

# User and password files

Secrets file =/etc/rsync. password

######################################## ###

# Sharing a file directory [module]

[Backup]

# Comtnt is a comment

Comment = www by old0boy

# Set the shared path.

Path =/backup

If you want to learn more about the parameters, refer to man rsyncd. conf.

2. Create users and backup directories

Useradd rsync-s/sbin/nologin-M:-s/sbin/nologin indicates that this user is created but cannot be used to log on to the system.

Passwd rsync: Create a password for him

Mkdir/backup creates a backup directory in the following directory. All files to be backed up by other clients are stored in this directory.
Chown-R rsync. rsync/backup change Directory Permissions

3. Create a password file.

Corresponds to secrets file =/etc/rsync. password in the configuration file

Touch/etc/rsync. password and edit vi to put your rsync password.

Alternatively, echo "rsync_backup: 123456">/etc/rsync. password

Rsync is your user _ backup is the name of the module you set in the configuration file. It is # in the configuration file content in (1) above. If the name in [backup] under the shared file directory is changed, you need to change it here, 123456 is the password you set.

It should be a password file, so the last permission is set.

Chmod 600/etc/rsync. password

4. Start the rsync Service

Rsync -- deamon

Then add it to the auto-start mode.

5. Configure the rsync Client

On the client, only two things are required.

1) create a password file.

Echo "123456">/etc/rsync. password you only need to put the user password of rsync on your server.

Chmod 600/etc/rsync. password

2) send the file.

6. Common Parameters on the rsync client.

Common Parameters of the rsync client (the meanings of specific parameters can be checked online .)

-V verbose mode output, progress information during transmission

-Compression during z Transmission

-A indicates that all data is equivalent to rtopgDl.

-E: specified channel

-- Exclude

-- Exclunde-from = directory where the file name is located.

-- Bwlimit Speed Limit

Rsync-avz/tmp rsync_backup@192.168.0.0: backup -- password-file =/etc/rsync. password

(The rsync_backup@192.168.0.219: backup is the name of your server backup Directory)

Now rsync configuration is complete !!! You can test the configuration.

Rsync other notes:

Rsync Security Optimization

1) if you only want to transmit data between local networks. First, you can bind the address to an intranet address Nic.

Rsync -- daemon -- address = 192.168.0.221

2) if the data is transmitted across data centers over the Internet, 1. Pull the leased line. 2. Use vpn

Advantages and disadvantages of rsync

Advantage 1. Incremental Backup synchronization and socket (daemon), centralized backup

Disadvantages:

1) synchronization of a large number of small files takes a long time, and sometimes the rsync process stops.

Solution: 1) package in synchronization. 2) drbd method synchronization (File System Synchronous replication block)

2) synchronize large files. Large files such as 10 Gb may sometimes encounter problems and be interrupted. Hidden Files are hidden before full synchronization.

At the same time, automatic backup can be performed with the specified time of the scheduled task.

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.