rsync配置脚本

#!/usr/bin/python
import os,sys


#Check rsync
pro = '/usr/bin/rsync'
if not os.path.isfile(pro):
    os.system('yum install -y rsync*')
    
rs = '/etc/xinetd.d/rsync'
os.system("sed -i '6s/yes/no/g' %s" % rs)


#set up configuration
conf = '/etc/rsyncd.conf'
#rsync directory
path = 'path = /root/hy' 
os.remove(conf)
if not os.path.isfile(conf):
    os.mknod(conf)
info = ['uid = root','gid = root','use chroot = no',\
'max connections = 10','[web]',path,'ignore errors',\
'read only = no','list = yes','hosts allow = 10.131.18.0/24',\
'auth users = root','secrets file = /etc/server.pass']
for i in info:
    men = open(conf,'a').write(i+'\n')
passw = '/etc/server.pass' #socket password
if not os.path.isfile(passw):
    os.mknod(passw)
data = open(passw).read()
if len(data) == 0:
    open(passw,'w').write('root:heyong.hyork')
#Start the program
command = 'service xinetd restart'
if os.system(command) == 0:

    print 'Promgram installtion is succeed'




配置文件:


uid = root
gid = root
use chroot = no
max connections = 10
[web]
path = /root/hy
ignore errors
read only = no
list = yes
hosts allow = 10.131.18.0/24
auth users = root
secrets file = /etc/server.pass


客户端命令:


rsync -vzrtopg --delete [email protected]::web /root/hy --password-file=/etc/client.pass




rsync  -auv localepath remoteuser @remoteip:remotepath \
rsync  -auv remoteuser @remoteip:remotepath localepath

你可能感兴趣的:(rsync配置脚本)