CentOS rsync configuration 1. server side configuration: # yum-y install xinetd (compile installation) Access http://rsync.samba.org/download the latest rsyncstable version wget http://rsync.samba.org/ftp/rsync/src/rsync-3.0.9.tar.gz wget http://rsync.samba.org/ftp/rsync/src/rsync-patches-3.0.9.tar.gz tar-zxvf rsync-3.0.9.tar.gztar-zxvf rsync-patches-3.0.9.tar.gz cd rsync-3.0.9. /configure make install after installation is complete and then the rsync service requires three files rsyncd. conf rsync service configuration file rsyncd. secr The user password of the ets rsync service must be the user rsyncd on the server. the motd rsync service logon prompt is password-safe rsyncd. the secrets permission must be modified to 600 chmod 0600 rsyncd. secrets files do not exist by default. You need to create mkdir-p/etc/rsyncd touch rsyncd by yourself. conf touch rsyncd. secrets touch rsyncd. motd # vi/etc/xinetd. d/rsync run the following code in service rsync {disable = yes socket_type = stream wait = no user = root server =/usr/bin/rsync server_args =-daemon log_on_failure + = USERID }. Change isable = yes to disable = no and start xinetd #/etc/init. d/xinetd start or service xinetd restart Note: if the server is installed with a firewall, remember to open the port. The default port is 873 # telnet 127.0.0.1 873 Trying 127.0.0.1... telnet: connect to address 127.0.0.1: connection refused # iptables-a input-s 192.168.0.0/255.255.255.0-p tcp-m tcp -- dport 873-j ACCEPT # iptables-a input-p tcp-m tcp -- dport 873-j DROP # vi/etc/rsyncd. conf (if this file does not exist, create it yourself) # Global Settings uid = root # Run rsync gid = root use chroot = no # Do not use chroot max connections = 20 # maximum number of connections secrets file =/etc/rsyncd. secrets # password file location, authentication file Settings, set user name and password log file =/var/log/rsyncd. log # specify the log file of rsync, instead of sending the log to syslog pid file =/var/run/rsyncd. pid # specify the rsync pid file lock file =/var/run/rsync. lock # specifies the lock file that supports the max connections parameter. The default value is/var/run/rsyncd. lock comment = hello world # motd file =/etc/rs Yncd. motd # Welcome information file name and storage location (this file does not exist, you can add it yourself) [backup] # Here is the authenticated Module name, on the client side, you must specify path =/titan24/www/repos # The image directory auth users = rsync # to authorize the account. The authenticated user name. If this row is not used, it indicates that it is anonymous. Multiple users are separated by read only = no # yes. the read-only value indicates NO, which indicates read-only mode, use NO hosts allow = 192.168.3.128 for data recovery # IP address of the server that is allowed to access hosts deny = * # blacklist list = true # allow column files # ignore errors # ignore unrelated IO errors # exclude = cache/111/cache/222/# ignored directory # vi/etc/rsyncd. secrets (set the user name and password for access (authentication) rsync: 111111 # User name: password to give the file the correct permissions # chown root: root/etc/rsyncd. secrets # chmod 600/etc/rsyncd. secrets # (must be 600) 2. It seems that the client has Installed rsync, if not installed: # yum-y install rsync asynchronous synchronization operation:/usr/bin/rsync-avz -- progress rsync@192.168.3.191 :: backup/www # crontab-e # (files can be synchronized every three minutes at a scheduled time) */3 *** rsync-avz -- progress rsync@192.168.3.191 :: the backup/www command is complete: # vi/etc/rsyncd. add the password rsyncofpass to the pas. Note that the password file on the client only requires the password instead of the user name! Change file permissions: # chmod 0600/etc/rsyncd. pas # rsync-vzrtopgu -- progress -- delete -- password-file =/etc/rsyncd. pas rsync_user@192.168.0.2: rsync_module_name1/www/In this command line-v in vzrtopg is verbose, z is compressed transmission, r is recursive, topg is a parameter that maintains the original attributes of a file, such as the owner and time. U is only used to synchronize updated files to avoid repeated updates to non-updated files. Note the clock synchronization between the two machines. -Progress indicates the detailed progress.-delete indicates that if the server deletes the file, the client also deletes the file to ensure true consistency. The following rsync_user@192.168.0.2: rsync_module_name1, after rsync_module_name1 is the module name, that is, in/etc/rsyncd. the custom name in conf. rsync_user is the user name that can be synchronized specified in the specified module. The last/www is the name of the local directory that is backed up. You can also use the-e ssh parameter to establish an encrypted connection. You can use-password-file =/password/path/file to specify the password file, so that you can use it in the script without entering the verification password interactively, note that only the owner can read the permission attribute of the password file. #/Usr/local/rsync/bin/rsync-vzrtopg-progress-delete rsync_user@192.168.0.2: rsync_module_name1/tmp/Password: Or you can set the password file because the system crontab is required for execution, therefore, the password file is read here, and the operation is successful. Synchronous command Description: 1 show directory content command -- a) rsyncb) rsync-rc) rsync jack@192.168.0.1: d) rsync ssh_user@192.168.0.1: Command description --- a) display directory content (level 1) b) recursive display directory content c) display remote host directory content * Note 1: Port mode, rsync-based user authentication * Note 2: the directory on rsync server must have xx7 permission. d) view remote host directory content * Note 1: remote shell mode, authentication based on local users of the system through ssh * Note 2: Only one colon (:) is used here (:), at the same time, the user name is the ssh user of the remote host, and the password is also the password of the ssh user. * Note 3: Use "to list information about the folder itself. To list folder content, use "/". Parameter description ---- r recursive operation on the directory 2 synchronization command between local directories -- a) rsync-av-progress/*** note (/) *** B) rsync-av-progressc) rsync-avu-progress-delete/d) rsync-av-progress-temp-dir =/tmp/command description ---) synchronize all files under the src-dir directory to the dst-dir directory B) synchronize all files under the src-dir directory to the dst-dir/src-dir directory c) update the src-dir directory differently to the dst-dir directory. If there is an increase/update, add or replace it. If there is a decrease, delete it. d) compared to) if-temp-dir =/tmp is added,/tmp is specified as a temporary swap zone. This avoids file synchronization errors caused by insufficient space in the target directory. Parameter description ---- a is equivalent to the-rlptgoD set-u is equivalent to-update, when the target file is newer than the source file, do not update-v displays the synchronized file-progress displays the percentage progress during file synchronization, transfer rate-delete deletes files in the target directory more than the source directory 3 remote synchronous command between hosts --) rsync-avz-progress jack@192.168.0.1:/B) rsync-avz-progress jack@192.168.0.1:/-password-file =/home/jack/rsync. jackc) rsync-avuz-progress-delete jack@192.168.0.1:/-password-file =/home/jack/rsync. jackd) rsync-avz-progress jack@192.168.0.1: // command description --- a) synchronize the contents of the local directory to the directory of the remote host 192.168.0.1, jack is the rsync database user (see 3. /etc/rsync. secrets) B) synchronize non-interactive login files by automatically reading user passwords. c) More-u and-deleted) synchronize the remote host content to the local directory. If you want to regularly execute crontab-e 20 00 *** rsync-azu -- password-file =/etc/rsyncd. password root@192.168.1.2: backup/backup>/dev/null 2> & 1