One-click rsync server shell script configuration in CentOS
1. Save the following code as a file and upload it to the server named rsync. sh.
- #! /Bin/bash
- # Rsync Written by zhumaohai
- # For more information please visit http://www.centos.bz
- Echo "Please input the rsync username :"
- Read username
- Echo "Please input the rsync username password :"
- Read password
- Echo "Please input the allow ip address :"
- Read allowip
- Echo "Please input the path you want to rsync :"
- Read rsyncpath
- Echo "====================== input all completed ============ ===================="
- Echo "================================ install rsync ============ =================="
- Yum-y install rsync
- Useradd $ username
- Mkdir/etc/rsyncd
- Cat>/etc/rsyncd. conf <EOF
- # Minimal configuration file for rsync daemon
- # See rsync (1) and rsyncd. conf (5) man pages for help
- # This line is required by the/etc/init. d/rsyncd script
- Pid file =/var/run/rsyncd. pid
- Port = 873
- # Address = $ serverip
- # Uid = nobody
- # Gid = nobody
- Uid = root
- Gid = root
- Use chroot = yes
- Read only = yes
- # Limit access to private LANs
- Hosts allow = $ allowip
- Hosts deny = *
- Max connections = 5
- Motd file =/etc/rsyncd. motd
- # This will give you a separate log file
- # Log file =/var/log/rsync. log
- # This will log every file transferred-up to 85,000 + per user, per sync
- # Transfer logging = yes
- Log format = % t % a % m % f % B
- Syslog facility = local3
- Timeout = 300
- [Home]
- Path = $ rsyncpath
- List = yes
- Ignore errors
- Auth users = $ username
- Secrets file =/etc/rsyncd. secrets
- EOF
- Echo "$ username: $ password">/etc/rsyncd. secrets
- Chmod 600/etc/rsyncd. secrets
- Cat>/etc/rsyncd. motd <EOF
- ++
- + Centos. bz rsync 2011-2012 +
- ++
- EOF
- /Usr/bin/rsync -- daemon -- config =/etc/rsyncd. conf
- Echo "/usr/bin/rsync -- daemon -- config =/etc/rsyncd. conf">/etc/rc. d/rc. local
- Ps-aux | grep rsync
2. Grant the script permission
- Chmod + x rsync. sh
3. Execute the script
- ./Rsync. sh
4. The client also needs to install rsync
See http://www.centos.bz/2011/06/rsync-server-setup/ for specific configuration