zoukankan      html  css  js  c++  java
  • rsync脚本

     1 #!/bin/bash
     2 yum -y install rsync >/dev/null
     3 cat >/etc/rsyncd.conf<<EOF
     4 ##全局配置                      
     5 uid = root
     6 gid = root
     7 use chroot = no
     8 max connections = 200
     9 timeout = 300
    10 pid file = /var/run/rsyncd.pid
    11 lock file = /var/run/rsync.lock
    12 log file = /var/log/rsyncd.log
    13  
    14 ##模块配置                    
    15 [backup]
    16 path = /data
    17 ignore errors
    18 read only = false
    19 list = false
    20 hosts allow = 10.0.0.0/24
    21 #hosts deny = 0.0.0.0/32
    22 auth users = rsync_backup
    23 secrets file = /etc/rsync.password
    24 EOF
    25 mkdir -p /data
    26 id rsync
    27 if [ $? -ne 0 ]; then
    28    useradd rsync -s /sbin/nologin -M
    29 else
    30    echo '用户存在'
    31 fi
    32 chown -R rsync.rsync /data/
    33 echo "rsync_backup:123456" >/etc/rsync.password
    34 chmod 600 /etc/rsync.password
    35 systemctl restart rsyncd.service
    36 systemctl enable rsyncd.service
    37 
    38 ssh root@10.0.0.76 "
    39 
    40 cat >/root/rsync.sh<<aaa
    41 #!/bin/bash
    42 
    43 id rsync
    44 if [ $? -ne 0 ]; then
    45 useradd rsync -s /sbin/nologin -M
    46 else
    47 echo '用户存在'
    48 fi
    49 echo "123456">/etc/rsync.password
    50 chmod 600 /etc/rsync.password 
    51 rsync -avz /root rsync_backup@10.0.0.75::backup --password-file=/etc/rsync.password
    52 aaa
    53 sh rsync.sh
    54 exit
    55 "

  • 相关阅读:
    Java 日志
    编写用例文档
    uml用例关系
    地址线和数据线
    Android总结
    DbUtil数据库连接
    PropertiesUtil
    log4j.properties配置
    自定义博客样式
    css给文字加下划线
  • 原文地址:https://www.cnblogs.com/xianglei_/p/12308330.html
Copyright © 2011-2022 走看看