码迷,mamicode.com
首页 > 其他好文 > 详细

rsync脚本

时间:2020-02-14 18:55:48      阅读:89      评论:0      收藏:0      [点我收藏+]

标签:error   erro   secret   echo   password   bsp   ssh   emctl   aaa   

 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 >/etc/rsyncd.conf<<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

 

rsync脚本

标签:error   erro   secret   echo   password   bsp   ssh   emctl   aaa   

原文地址:https://www.cnblogs.com/xianglei_/p/12308330.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!