Rsync+inotify configuration of automatic backup server

Source: Internet
Author: User
Tags inotify

Rsync+inotify configuration of automatic backup server

1 Backing up the server ip:192.168.1.106

Client ip:192.168.1.107

2.

#yum-y install rsync xinetd gcc gcc-c++

Install both of these services, as well as the C + + compiler (if not in advance, to avoid the compiler when compiling binary files)

3. Create a rsyncd.conf on the server side (192.168.1.106)/etc

#service iptables Stop shuts down the firewall with SELinux

#vi/etc/selinux/config will selinux=disabled

#vi/etc/rsyncd.conf

UID = nobody

GID = Nobody

Max connections = 200

Timeout = 600

Use chroot = no

Hosts allow = *

PID File=/var/run/rsyncd.pid

#syslog facility = Local7

Log File=/var/log/rsyncd.log

#rsync con**

#The ' Standard ' things

[Backup]

Path =/backup//Create a directory under the root of the server to back up the files of the client

Ignore errors//Ignore some errors

Read Only = no

List = no

Auth users = test//authenticated user

Secrets file =/etc/rsyncd.secrets Authenticated user's username and password location


4. Compile/etc/xinetd.d/rsync on the server side (192.168.1.106)

#vi/etc/xinetd.d/rsync

Service rsync

{

Disable = no//Change the original yes to no OK

Flags = IPV6

Socket_type = Stream

wait = no

user = root

Server =/usr/bin/rsync

Server_args =--daemon

Log_on_failure + = USERID

}

3 h Create authenticated user and password files on the server side

#vi/etc/rsyncd.secrets

Test:test

: Wq

Save exit

6. Start the Rsync service

#service xinetd Restart

#/usr/bin/rsync--daemon--config=/etc/rsyncd.conf

7. Note The issue of permissions causes the client to be unable to connect

#chmod 777/backup

#chmod 600/etc/rsyncd.secrets

Password file must be changed to 600 permissions, or the client will be connected when the error

Configuration of the client (192.168.1.107)

#yum install gcc gcc-c++ rsync xinetd

#service xinetd Restart

#service iptables Stop

#netstat-TNL |grep 873

1. Vi/etc/rsyncd.secrets

testpasswd

: Wq

Save exit

2. Modify Permissions

#chmod 600/etc/rsyncd.secrets

3. On the client

#rsync-VZRTOPG--password-file=/etc/rsyncd.secrets/aaa [email protected]::backup

Where AAA is the directory to be backed up locally to the server



This is for manual synchronization, the command is also very cumbersome to write it to a shell corner of the book through the crontab call for automatic synchronization


But there is one more efficient way to do this is to say the rsync+inotify combination

Http://inotify-tools.sourceforge.net download the appropriate installation package

# TAR-ZXVF Inotify-tools-3.14.tar.gz

#cd inotify-tools-3.14

#./configure && make && make install


Write a shell corner book after the installation is complete

#vi rsync.sh

#!/bin/bash

Src=/aaa

Des=backup

ip=192.168.1.106

/usr/local/bin/inotifywait-mrq--timefmt '%d/%m/%y%h:%m '--format '%T%w%f '-E modify,delete,create,attrib $src | While read file

Do

RSYNC-VZRTOPG--delete--progress $src [email protected] $ip:: $des--password-file=/etc/rsyncd.secrets &&

echo "$src was rsynced"

Done

: Wq


#nohup sh/root/rsync.sh & Note the middle space

This ensures that when you modify the files inside the client's/aaa, it is immediately updated to the server side to achieve fast data consistency.


This article is from the Linux cluster application blog, so be sure to keep this source http://ipinco.blog.51cto.com/2929516/1745183

Rsync+inotify configuration of automatic backup server

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.