Inotify + rsync for real-time file backup

Source: Internet
Author: User


Inotify + rsync implements real-time file backup 1. inotify inotify is a powerful fine-grained and asynchronous file system event monitoring mechanism. The Linux kernel has been added to Inotify since 2.6.13, inotify can be used to monitor various events in the file system, such as adding, deleting, modifying, and moving. However, inotify only provides the C language interface, which is inconvenient to call. Therefore, inotify-tools must be installed first. installation Method: yum install inotify-tools; apt-get install inotify-tools II. the Rsync www.2cto.com backup tool works the same as tar, cpio, and other tools, but can be backed up to other machines without compression before transmission. Configure rsync on the target server to create/etc/rsyncd. confShell code uid = user gid = usergroup use chroot = no timeout = 600 pid file =/var/run/rsyncd. pid lock file =/var/run/rsyncd. lock log file =/var/log/rsyncd. log [web1] path =/photo/system/ignore errors read only = no list = no auth users = user secrets file =/etc/user. pwd user. pwd records the user name and password of the user, in the format of user: password www.2cto.com source server shell file
Shell code #! /Bin/bash SRC =/web/system/DST = user@192.168.0.162: web1/usr/bin/inotifywait-mrq-e close_write, create, attrib $ {SRC} | while read d e f do/usr/bin/rsync-vzrtopg -- progress $ SRC $ DST -- password-file =/etc/picback. pwd done picback. pwd records the password of the user on the target 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.