Rsync + inotify configure the real-time synchronization server

Source: Internet
Author: User
Tags inotify rsync

1. install the inofity-tools tool and rsync on the server (note that the server is the backup system), and install rsync on the client (that is, the backup system stores the backup files of the server)

2. Configure the/etc/rsyncd. conf file on the client. The content is as follows:

 
Uid = nobodygid = nobodyuse chroot = nomax connections = 10 strict modes = yespid file =/var/run/rsyncd. pidlock file =/var/run/rsync. locklog file =/var/log/rsyncd. log [yang11]
 
# This directory must contain Path =/home/Linux/savecomment = Linux Home dataignore errorsread only = nowrite only = nohosts allow = * hosts deny = 172.16.16.11list = falseuid = rootgid = rootauth users = backupsecrets file =/etc/server. pass

Create the/etc/server. Pass file on the client and set the permission to 600. The content is as follows:

Backup: yang123

Start rsync -- daemon on the client.

3. Write a script on the backup system (that is, the system where the inofity-tools tool and rsync tool are installed). Assume the name is rsync_inotify.sh. The content is as follows:

#! /Bin/bashhost1 = 172.16.16.202src =/home/Linux/linuxtoolsuser = "backup" modelname = "yang11"/usr/bin/inotifywait-mrq -- timefmt '% Y/% m/% d % H: % m' -- format' % T % w % F % e'-e modify, delete, create, attrib $ SRC \ | while read filesdo/usr/bin/rsync-vzrtopg -- delete -- Progress -- password-file =/etc/rsync. pass $ SRC $ user @ $ host1: $ modelnameecho "$ files was rsynced">/tmp/rsync. log 2> & 1 done

4. Run the script.

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.