Rsync is so convenient for file backups that I feel I have to install it on my own server. The rsync server here is a simple and rough configuration (directly on the code), for details do not do in-depth discussion, but it is certain that the server must be able to run up, for the novice this is the most important, is not it?
A What is rsync
Rsync,remote Synchronize as implies meaning that it is a remote synchronization software, it synchronizes files at the same time, you can keep the original file permissions, time, soft and hard links and other additional information. Rsync uses the rsync algorithm to provide a quick way for file synchronization between a client and a remote file server, and it can be transferred via SSH, so it's very confidential and it's free software.
Rsync includes some of the following features:
1. Can update the entire directory and tree and file system;
2. Selectively maintain symbolic chain, hard link, file belonging, permission, equipment and time, etc.
3. For the installation, no special permission requirements;
4. For multiple files, the internal pipeline reduces the delay of file waiting;
5. Can use rsh, SSH or direct port as the transmission port;
6. Support the anonymous rsync synchronization files, is the ideal image tool;
Two build rsync serverInstallation of 1.rsyncA. Source Code compilation installation
: https://rsync.samba.org/
[[Email protected] install]# tar xvf rsync-3.1.1.tar.gz[[email protected] install]# CD Rsync-3.1.1[[email protected] Rsyn c-3.1.1]#./configure--prefix=/usr/local[[email protected] rsync-3.1.1]# make && make Install[[email protected ] rsync-3.1.1]# Cd/usr/local/bin[[email protected] bin]# ll|grep rsync-rwxr-xr-x. 1 root root 1368856 September 12:01 rsync
B. Package Installation
sudo apt-get install rsync # #注: Online installation methods such as Debian, Ubuntu, yum install rsync # #注: Online installation methods such as Fedora, Redhat, Rpm-ivh Rsyn C # #注: Fedora, Redhat and other RPM package installation method, # #其它Linux发行版, please use the appropriate package management method to install.
Configuration of 2.rsync
Rsync mainly has the following three profiles rsyncd.conf (Master profile), Rsyncd.secrets (password file), RSYNCD.MOTD (RYSNC server information)
Server configuration file (/etc/rsyncd.conf), the file does not exist by default, create it.
[[email protected] local]# cd / etc/[[email protected] etc]# mkdir rsync.d[[email protected] etc]# cd Rsync.d/ [[email protected] rsync.d]# touch rsyncd.conf[[email protected] rsync.d]# touch rsyncd.secrets[[email protected] rsync.d]# touch rsyncd.motd[[email protected] rsync.d]# chmod 600 rsyncd.secrets # #将rsyncd. Secrets The file attribute of this password file is set to root with, and permission to be set to 600[[email protected] rsync.d]# ll Total dosage 0-rw-r--r--. 1 root root 0 9 month 21 12:14 Rsyncd.conf-rw-r--r--. 1 root root 0 9 Month 21 12:14 RSYNCD.MOTD-RW-------. 1 root root 0 9 Month 21 12:14 rsyncd.secrets
The following is the configuration of rsyncd.conf
# distributed under the terms of the gnu general public license v2# 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.pidport = 873address = 115.28.34.xxx #修改为自己的ipuid = rootgid = rootuse chroot = yesread only = yes#limit access to private lanshosts allow=*hosts deny=*max connections = 5motd file = /etc/rsync.d/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 = yeslog format = %t %a %m %f %bsyslog facility = local3timeout = 300[mysql_backup]path = /data/mysql_backuplist=yesignore errorsauth users = yearnfarsecrets file = /etc/rsync.d/rsyncd.secretscomment = backup mysqlexclude = git/
The following is the configuration of the Rsyncd.secrets
yearnfar:123456
The following is the configuration of the RSYNCD.MOTD
++++++++++++++++++++++++++++++++++++++++++++++welcome to use the mike.org.cn rsync services! centos6.3 yearnfar++++++++++++++++++++++++++++++++++++++++++++++
3. Start the script
[[email protected] rsync.d]# vi /etc/init.d/rsync #!/bin/bash## rsyncd this shell script takes care of starting and stopping# standalone rsync.## chkconfig: - 99 50# description: rsync is a file Transport daemon# processname: rsync# config: /etc/rsync.d/rsyncd.conf# source function library. /etc/rc.d/init.d/functionsretval=0rsync= "/usr/local/bin/rsync" prog= "rsync" Cfile= "/etc/rsync.d/rsyncd.conf" Start () { # start daemons. [ -x $rsync ] | | { echo "Fatal: no such programme "; exit 4; } [ -f $CFILE ] | | { echo "fatal: Config file does not exist ";exit 6; } echo -n $ "starting $prog: " daemon $rsync --daemon --config= $CFILE RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog echo return $RETVAL}stop () { # stop daemons. echo -n $ "Stopping $prog: " killproc $prog -QUIT RETVAL=$? echo [ $RETVAL - eq 0 ] && rm -f /var/lock/subsys/$prog return $RETVAL}# call the function we definedcase "$" in start) start ;; stop) stop ;; restart|reload) stop start RETVAL=$? ;; status) status $prog retval=$? ;; *) echo $ "usage: $0 {start|stop| Restart|reload|status} " exit 2esacexit $RETVAL [email  PROTECTED] RSYNC.D]# CHMOD +X /ETC/INIT.D/RSYNC[[EMAIL PROTECTED] RSYNC.D] # /etc/init.d/rsync start is starting rsync: [Determine] [[email protected] rsync.d]# chkconfig --add /etc/init.d/rsync ## Add to boot [[email protected] rsync.d]# Chkconfig --level 235 rsync on ## Add to boot boot
4. Test the connection
[Email protected] rsync.d]# rsync--list-only [email protected]::mysql_backup++++++++++++++++++++++++++++++++++++++ ++++++++welcome to use the mike.org.cn rsync services! centos6.3 Yearnfar ++++++++++++++++++++++++++++++++++++++++++++++password:drwxr-xr-x 4096 2015/09/20 15:24:06. drw Xr-xr-x 4096 2015/09/21 04:00:01 201509
Rsync Server Setup