The configuration and use of rsync

Source: Internet
Author: User
Tags comparison table rsync

RYSNC's homepage address is:
http://rsync.samba.org/
Currently the latest version is 3.0.6. You can choose to download from the original website:
http://rsync.samba.org/ftp/rsync/
You can also choose to download from this site: rsync 3.0.6

First, download, install rsync
#tar ZXVF rsync-3.0.6.tar.gz
#cd rsync-3.0.6
#./configure--prefix=/usr/local/rsync
#make
#make Install
Normal installation of RH is with rsync, running files on the/usr/bin/rsync


Second, configure the rsync server
1. Start rsync
[Email protected] ~]# Vim/etc/xinetd.d/rsync
Turn disable = No to change Yes to No
#default: Off
# description:the Rsync server is a good addition to an FTP server, as it \
# allows CRC Checksumming etc.
Service rsync
{
Disable = no
Flags = IPV6
Socket_type = Stream
wait = no
user = root
Server =/usr/bin/rsync
Server_args =--daemon
Log_on_failure + = USERID
}
Start rsync with the system
[[email protected] ~]# chkconfig rsync on

2. Configure/etc/rsyncd.conf (manual generation required)
rsyncd.conf parameters are written on the top of the global parameters and written in the module is the module parameters
#vi/etc/rsyncd.conf
Global parameters
UID = root//user running the rsync daemon
GID = root//group running the rsync daemon
Use chroot = no//no chroot
Max connections = 4//maximum number of connections is 4
Strict modes =yes//Whether to check the password file permissions
Port = 873//default port 873
Note: The following files are files that are automatically generated after the Rsync service is installed
Log File=/var/log/rsyncd.log
PID File=/var/run/rsyncd.pid
Lock File=/var/run/rsyncd.lock

Module parameters
[Caiwubeifen]//Here is the module name of the authentication, on the client side need to specify
comment= backup Caiwu//comment information for this module.
Path=/home/backup//need to back up the directory path of the mirror, essential
Ignore errors//ignoring some unrelated IO errors
Read Only = no//With Yes, only from the service side of the data, unable to push the data to the service side.
Auth users = CAIWU//authenticated user name, if no this line indicates is anonymous, this user is not system-independent
Secrets file=/etc/rsync.pas//Password and user name comparison table, password file generated by itself
#hosts ALLOW=172.16.78.0/22//Allow host
#hosts deny = 0.0.0.0/0//Disallow Host

3, configure the rsync password (in the above configuration file has already written the path)/etc/rsync.pas (the name casually write, as long as the same as in the above configuration file), format (one line a user)
Account: Password
[Email protected] ~]# Vim/etc/rsyncd.pas

caiwu:123456
Permissions: Because Rsync.pas stores the user name and password for the rsync service, it is important. To set Rsync.pas to root, with a permission of 600.
[Email protected] ~]# cd/etc/
[Email protected] etc]# chown root.root Rsync.pas
[Email protected] etc]# chmod Rsync.pas
[email protected] etc]# ll Rsync.pas
-RW-------. 1 root root 13 April 02:51 Rsync.pas
3.RSYNCD.MOTD (Configure welcome information, optional) information to enter the content arbitrarily.
[Email protected] etc]# VIM/ETC/RSYNC.MOTD

Welcome to use the Lecaicaiwu rsync services!
4. Let the configuration take effect
[Email protected] ~]# service xinetd restart
Stop xinetd: [OK]
Starting xinetd: [OK]

Third, start the rsync server
Two ways to start rsync server
1. Start the rsync server (standalone boot)
#/usr/bin/rsync–daemon

2. Start the rsync server (with XINETD super process boot)
#/etc/rc.d/init.d/xinetd Reload
Example:
[Email protected] ~]#/etc/rc.d/init.d/xinetd Reload
Reload configuration: [OK]

Four: Join rc.local
In various operating systems, the RC file storage location is different, can be modified to enable the system to load the rsync--daemon
[Email protected] ~]# vim/etc/rc.local
Add a row/usr/bin/rsync--daemon
Example:
#!/bin/sh
#
# This script is executed *after* all and the other init scripts.
# can put your own initialization stuff in here if you don ' t
# want to does the full Sys V style init stuff.

Touch/var/lock/subsys/local
/usr/bin/rsync--daemon
Five. Check rsync
[[email protected] ~]# netstat-a | grep rsync
tcp        0      0 *:rsync                      *: *                          LISTEN
[[email protected] ~]# lsof-i:873
command  PID USER    fd   TYPE DEVICE size/off NODE NAME
xinetd  4189 root    5u  IPv6 2330 04      0t0  TCP *:rsync (LISTEN)
Server-side files:
[[email protected] home]# Cd/home /backup/
[[email protected] backup]# ll
Total usage 4
-rw-r--r--. 1 root root    0 April   16 00:03 Test
Drwxr-xr-x. 2 root root 4096 April   00:04 test1

Six. Turn off firewall and communication restrictions SELinux
[[email protected] home]# vi/etc/selinux/config
selinux=disabled   Change to Disabled is not changed
[[email protected] home]# setenforce 0 changed selinux does not restart, file effective
[[email protected] home] # service Iptables stop     have the option to permanently turn off
Seven. Configure rsync client
1. Set Password
[[email protected] ~]# Vi/etc/rsync.pas
[[email protected] etc]# cat/etc/rsync.pas
123456
[[email protected] etc]# cd/etc/
[[email protected] etc]# ll Rsync.pas
-rw-------1 root root 7 Apr 00:57 rsync.pas
[[email  ;p rotected] etc]# chown root.root rsync.pas
[[email protected] etc]# chmod rsync.pas
  Similarly turn off firewalls and traffic limits SELinux.
fetch files from server
2[[email protected] home]#/usr/bin/rsync-vzrtopg--progress--delete [email protected ]::caiwubeifen/home/backup--password-file=/etc/rsync.pas
Receiving incremental file list

Sent bytes received 126 bytes 378.00 Bytes/sec
Total size was 0 Speedup is 0.00
[Email protected] home]# CD backup/
[email protected] backup]# LL
Total 4
-rw-r--r--1 root root 0 Apr test
Drwxr-xr-x 2 root root 4096 Apr test1
Uploading files to the server side
[Email protected] backup]#/USR/BIN/RSYNC-VZRTOPG--progress--password-file=/etc/rsync.pas/home/backup [email prote Cted]::caiwubeifen
Sending incremental file list
backup/
Backup/test
0 100% 0.00kb/s 0:00:00 (xfer#1, TO-CHECK=2/4)
backup/jiangwei/
backup/test1/

Sent bytes received bytes 119.33 bytes/sec
Total size was 0 Speedup is 0.00

rsync command Parameters
-V indicates verbose detailed display
-Z means compression
-R means recursive recursion
-T means keeping the original file creation time
-O means to keep the original file owner
-p means to keep the parameters of the original file
-G means to keep the original file's owning group
-A archive mode
-P represents the option function in place of both-partial and-progress
-e SSH establishes an encrypted connection.
--partial prevents rsync from deleting the copied portion when the transmission is interrupted (if the transfer is interrupted while the file is being copied, the default action of Rsync is to undo the pre-action, i.e. from the target machine
Delete a portion of a file that has been copied. )
--progress means to show detailed progress
--delete means that if the server side deletes the file, then the client also deletes the file accordingly, maintaining true consistency.
--exclude does not contain the/ins directory
--size-only This parameter is used in two folders is only a few new files in the source folder, there is no duplicate and modified files, because the content can be modified to the same size, and is skipped. This parameter can greatly improve the efficiency of synchronization because it does not need to check whether the contents of a file of the same name are the same.
--password-file to specify the password file that contains the password for the specified authenticated user on the server side.
This can be used in the script without the need to interactively enter the authentication password, it is important to note that this password file permission property to be set to be only master readable.
[Email Protected]::caiwubeifen
Caiwu refers to a user who specifies authentication on the server side
172.16.22.141 refers to the server-side IP
:: Caiwubeifen Indicates the module name that needs to be synchronized on the server side;

Eight, automatic operation
vi/root/time.sh
Content:
/USR/BIN/RSYNC-VZRTOPG--progress--delete [email protected]::caiwubeifen/home/backup--password-file=/etc/ Rsync.pas

2) crontab-e
Ten * * * */root/time.sh Test


This article is from the "hope of the Dog" blog, be sure to keep this source http://8874480.blog.51cto.com/8864480/1633300

The configuration and use of rsync

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.