In linux, rsync is deployed in centos x64 6.8 to implement remote file backup and synchronization, and centosrsync

Source: Internet
Author: User

In linux, rsync is deployed in centos x64 6.8 to implement remote file backup and synchronization, and centosrsync

By default, centos has been installed. If not, check it first.

Rpm-qa rsync

Yum install rsync

Server (Backup Server)

1. Write the configuration file

Vi/etc/rsyncd. conf

/Etc/rsyncd: configuration file for rsync daemon mode

See rsyncd. conf man page for more options.

Configuration example: uid = rsync gid = rsync

Use chroot = yes

List = yes

Address = 192.161.1.1 max connections = 10 pid file =/var/run/rsyncd. pid log file =/var/log/rsyncd. log

Exclude = lost + found/

Transfer logging = yes

Timeout = 900

Ignore nonreadable = yes

Dont compress =. gz. tgz. zip. z. rpm. deb. bz2 [data] path =/www/data/transfer logging = yes ignore errors

Read only = no list = no hosts allow = 192.168.1.1, 192.168.1.2

Auth users = test secrets file =/etc/rsync. password

[Ftp]

Path =/home/ftp

Comment = ftp export area

Note:

Uid = nobody

The user who performs synchronization or backup, nobody is any user

Gid = nobody

The group to be backed up. The nobody is any group.

Use chroot = no

If "use chroot" is set to true, rsync first transfers the chroot file to the directory specified by the path parameter before transferring the file. The reason for doing so is to implement additional security protection, but the disadvantage is that the root permission is required, and the directory file pointed to by the external symbolic connection cannot be backed up. The default chroot value is true, but this is not required. I choose no or false.

List = no

Column list not allowed

Max connections = 10

Max connections

Timeout = 600

Overwrite the specified IP timeout time, that is, the rsync server will not always wait for a crashed client.

Pidfile =/var/run/rsyncd. pid

Pid file storage location

Lock file =/var/run/rsync. lock

Lock file storage location

Log file =/var/log/rsyncd. log

Storage location of log files

[Data]

Here is the name of the authentication module, that is, the name published externally, just like the samba syntax.

Path =/www/data/

Here is the directory involved in synchronization

Ignore errors

Some unrelated IO errors can be ignored.

Read only = no

Readable and writable

List = no

Column list not allowed

Hosts allow = 192.168.1.0/255.255.255.0

The syntax is the same as that of samba. Only network segments of 192.168.21.0/24 can be synchronized, and everything else is rejected.

Auth users = test

Authenticated User Name

Secrets file =/etc/rsyncd. password

Password File storage address

Note:

[Backup] Authentication Module name and path =/www/backup/directory for synchronization

You should remember the path here. Do not simply complete it by setting it. You must know that this is the authentication module, and the data backed up from the client will be stored here in the future.

Auth users = redhat authenticated user name

This name is a real user on the server side. Do not follow the steps directly but ignore this. If this is missing on the server side, I don't think your data synchronization will work out. Remember this.

2. Create a user

Groupadd rsync

Useradd rsync-g rsync

3. Create a password

Echo "rsync: rsync666">/etc/rsync. password

Chmod 600/etc/rsync. password

4. Start the service and start the self-starting open port

Rsync -- daemon

Self-starting

Vim/etc/rc. local

Join

/Usr/bin/rsync -- daemon

Open Port

Iptables-a input-p tcp -- dport 873-j ACCEPT

Service iptables save

Service iptables restart

5. Set Backup Directory Permissions

Chown-R rsync: rsync/www/data/

Client settings (upload server) ========================================================== === 6. set the password for the server (sync666)

Echo "rsync666">/etc/rsync. password

Chmod 600/etc/rsync. password

7. Compile the upload script

Vi/root/rsync. sh

#! /Bin/bash rsync-avzP/www/data/test@192.168.1.3: data -- password-file =/etc/rsync. password

Note:

/Www/data/is the directory to be uploaded

Data is the [data] Option configured for the server

8. Set scheduled task running

Crontab-e

Join

00 06 ***/root/rsync. sh

Synchronization is performed at every day.

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.