永利澳门游戏网址304:inotify一键安装脚本,完毕inotify同盟rsync实时备份

三、关于inotify原理(略)

1.布置服务端rysnc
    vi /etc/rsyncd.conf里的剧情
uid = rsync     
gid = rsync     
use chroot = no     
max connections = 200     
timeout = 100     
pid file = /var/run/rsyncd.pid     
lock file = /var/run/rsync.lock     
log file  = /var/log/rsyncd.log     
[backup]     
path = /backup/     
ignore errors     
read only = false     
list =  false     
hosts allow = 199.101.117.0/24     
hosts deny = 0.0.0.0/32     
auth users = rsync_backup     
secrets file = /etc/rsync.password

client:192.168.122.55,192.168.122.56

 

4.1服务端脚本

[root@testvpn backup]#echo “rsync_backup:oldboy”>
/etc/rsync.password 

手拉手目录:/data/html

${inotify_home}/bin/inotifywait -mrq –timefmt ‘%d%m%y %H:%M’ –format
‘%T %w%f’ -e close_write,delete,create,attrib $src
| while read file
  do
    cd $src && rsync -aruz -R –delete ./ –timeout=100
$user@$host01::$dst –password-file=${rsync_passfile} >/dev/null
2>&1
    done
exit 0
##如上是本子内容
[root@twstaiton2 ~]#nohup ./realtime.sh &  #启航后台监听脚本
在/backup目录下测量试验touch
{1..100},在服务端的/backup立时会同步那九18个文件,成功!
假定不成功供给手动二个个指令检查,有关rsync的服务端配置,详见 昂Corasync
的简易利用与布置那篇文章

  1. #!/bin/bash
    1. yum install rsync -y
  2. mkdir -p /data/html
    #万一要一齐的不是此目录,能够依靠实际需求加上目录
  3. #wget
  4. tar xzvf inotify-tools-3.14.tar.gz
  5. cd inotify-tools-3.14
  6. ./configure
  7. make
  8. make install
    1. #cponfigure inotify
    1. cat >>/home/rsync.sh <<EOF
  9. #!/bin/bash
  10. src=/data/html/ #共同的源目录
  11. des=www
  12. host=”192.168.122.55 192.168.122.56″
  13. /usr/local/bin/inotifywait -mrq –timefmt ‘%d/%m/%y %H:%M’ –format
    ‘%T %w%f’ -e modify,delete,create,attrib $src | while read files
  14. do
  15. for hostip in $host
  16. do
  17. rsync -vzrtopg –delete –progress –password-file=/etc/rsyncd.secrets $src
    root@$hostip::$des
  18. done
  19. echo “${files} was rsynced” >>/tmp/rsync.log 2>&1
  20. done
  21. EOF
    1. #confiugre secret
  22. cat >>
    /etc/rsyncd.secrets <<EOF
  23. 123456
  24. root:123456
  25. EOF
  26. chmod 0600 /etc/rsyncd.secrets
    1. #setting running onboot
  27. echo “nohup /bin/bash /home/rsync.sh &” >> /etc/rc.local
  28. nohup /bin/bash /home/rsync.sh &

 

  1. #!/bin/bash
      1. yum install rsync -y
  2. mkdir -p /data/html
    1. #configure rsyncd daemon
  3. cat >>
    /etc/rsyncd.conf <<EOF
  4. uid = root
  5. gid = root
  6. use chroot = no
  7. max connections = 5
  8. pid file = /var/run/rsyncd.pid
  9. lock file = /var/run/rsync.lock
  10. log file = /var/log/rsyncd.log
    1. [www]
  11. path=/data/html/
  12. comment = update
  13. ignore errors
  14. read only = no
  15. list = no
  16. hosts allow = 192.168.122.0/24
  17. auth users = root
  18. 永利澳门游戏网址304,uid = root
  19. gid = root
  20. secrets file = /etc/rsyncd.secrets
  21. EOF
    1. #configure secret
  22. cat >>
    /etc/rsyncd.secrets <<EOF
  23. 123456
  24. root:123456
  25. EOF
  26. chmod 0600 /etc/rsyncd.secrets
  27. echo “rsync –daemon” >> /etc/rc.local
  28. rsync –daemon

##rsync_backup是虚拟账户,到时候客商端连接就用那一个账户和密码oldboy。
[root@testvpn backup]#chmod 600 /etc/rsyncd.password                 
                ###设置成外人都无法观察,因为中间有密码
[root@testvpn backup]#rsync –daemon 

顾客名与密码都以www.linuxidc.com

 

免费下载地址在

if [ ! -e “$src” ]
|| [ ! -e “${rsync_passfile}” ]
|| [ ! -e “${inotify_home}/bin/inotifywait” ]
|| [ ! -e “/usr/bin/rsync” ];
then
echo “Check File and Folder”
exit 0
fi

4.2 客商端脚本

#开发银行过程

五、测验进程。
 
略过测量检验进程,大家可以友善测量试验同步效果。
 
六、附一键安装包

#!/bin/bash
host01=199.101.117.34
src=/backup
dst=backup
user=rsync_backup
rsync_passfile=/etc/rsync.password
inotify_home=/usr/local/inotify

一、境况描述

inotify-tools+rsync实时同步文件安装和安排
http://www.linuxidc.com/Linux/2012-06/63624.htm

四、操作进程

运用inotifywait监察和控制主机文件和目录
http://www.linuxidc.com/Linux/2013-03/81075.htm

server:192.168.122.54

 

server端有任何数据更新,就要联合到client端,实时同步

兑现inotify协作rsync实时备份

永利澳门游戏网址304 1

途乐sync
的详尽介绍
:请点这里
汉兰达sync
的下载地址
:请点这里

发表评论

电子邮件地址不会被公开。 必填项已用*标注