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.