rsync脚本
Posted xianglei_
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 >/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脚本的主要内容,如果未能解决你的问题,请参考以下文章