INotify a script that automatically monitors and synchronizes to the server

Source: Internet
Author: User
Tags inotify rsync

Function:

Monitor a directory on the specified server and automatically sync to another server

#!/bin/bash # author:honway.liu # date:2012-07-04 r1=61.147.88.114 r2=61.147.88.115 r3=222.186.32.15 desthostdir=/dat A/mp3 srcdir=/data/music/mp3/song11 log=/var/tmp/mp3sync.log inotifywait-mr--timefmt '%d/%m/%y%H:%M '--format  '%T%w%f '-E close_write,modify,delete,create,attrib $SRCDIR | While read DATE time DIR FILE; Do filechange=${dir}${file} rsync-avz--password-file=/etc/rsyncd/rsyncd.pass $FILECHANGE darl Ing@${r1}::root${desthostdir} &>/dev/null && \ echo "at ${time} on ${date}, file $FILECHANGE is BAC ked up via rsync ">> $LOG rsync-avz--password-file=/etc/rsyncd/rsyncd.pass $FILECHANGE DARLING@${R2} :: root${desthostdir} &>/dev/null && \ echo "at ${time} on ${date}, file $FILECHANGE is backed up V IA rsync ">> $LOG rsync-avz--password-file=/etc/rsyncd/rsyncd.pass $FILECHANGE darling@${r3}::root${
    Desthostdir} &>/dev/null && \   echo ' at ${time} on ${date}, file $FILECHANGE is backed up via rsync ' >> $LOG done 

This article address: http://www.bianceng.cn/Servers/zs/201602/49605.htm

This article comes from "Acridine a Pooh" blog, please be sure to keep this source http://gm100861.blog.51cto.com/1930562/935176

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.