Rsync + inotify Real-time backup

Source: Internet
Author: User
Tags inotify rsync

rsync configuration steps

Server-side

1. Install rsync

Yum Install rsync

2. Modify the configuration file

Vim/etc/rsyncd.conf #默认不存在需要自己创建

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

Uid=rsync

Gid=rsync

Use Chroot =no

Max connections=200

timeout=600

PID File=/var/run/rsyncd.pid

Lock file =/var/run/rsyncd.lock

Log file =/var/log/rysncd.log

[ZQ]

Path=/zq

Ignore errors

Read Only=no

List =no

Hosts ALLOW=192.168.1.0/24

Auth USER=ZQ

Secrets file=/etc/web.passwd

3. Create login user and password

Echo zq:123456 >/etc/web.passwd

Client

1. Create a password file

Echo 123456 >/etc/web.passwd

2. Installing Inotify-tools

wget http://120.52.73.47/tenet.dl.sourceforge.net/project/inotify-tools/inotify-tools/3.13/inotify-tools-3.13.tar.gz

Tar XF inotify-tools-3.13.tar.gz

CD inotify-tools-3.13

./configure--prefix=/usr/local/inotify-tools/

Make && make install

3. Create monitoring monitoring and replication scripts

# # # #inotify脚本 # #

#!/bin/sh

Src=/backup

Des=zq

rsync_passwd=/etc/web.passwd

ip=192.168.1.127

User=zq

CD ${SRC}

/usr/local/inotify-tools/bin/inotifywait-mrq--format '%w%f '-e modify,create,delete,attrib,close_write,move./| While Read line

Do

RSYNC-AVZR--timeout--password-file=${rsync_passwd} $line ${user}@${ip}::${des} &>/dev/null

Done

4. Set inotify Script execution permissions:

chmod a+x/rsync.sh

5. Add the script to the boot auto-start file

echo "/root/inotify.sh &" >>/etc/rc.local


Complete

This article is from the "Ops Little Prince" blog, please be sure to keep this source http://superzhangqiang.blog.51cto.com/6399950/1759193

Rsync + inotify Real-time backup

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.