Rsync Installation Use Details _ server other

Source: Internet
Author: User
Tags anonymous auth chmod comparison table file permissions iptables rsync rsync usage

Rsync Software Introduction:
Rsync is a data mirroring Backup tool under Unix-like systems, and--remote sync can be seen from the name of the software. Its characteristics are as follows:
Can be mirrored to save the entire directory tree and file system.
It is easy to maintain the original file permissions, time, soft and hard links and so on.
can be installed without special permissions.
Optimized flow, high efficiency of file transfer.
You can use RCP, ssh, and so on to transfer files, of course, through a direct socket connection.
Support for anonymous transmission, to facilitate the use of Web site mirror image.

Software downloads

RYSNC's home address is:
http://rsync.samba.org/
The latest version is 2.4.6. You can choose to download from the original web site:
http://rsync.samba.org/ftp/rsync/
。 You can also choose to download from this site: rsync 2.4.6


First, download, install rsync

#tar ZXVF rsync-2.6.9.tar.gz
#cd rsync-2.6.9
#./configure--prefix=/usr/local/rsync
#make
#make Install
Normal when the RH is installed with rsync, run files on the/usr/bin/rsync

Second, configure Rsync server

1. Start rsync
#vi/etc/xinetd.d/rsync
Change the original yes to No
Service rsync
{
Disable = no
Socket_type = Stream
wait = no
user = root
Server =/usr/bin/rsync
Server_args =--daemon
Log_on_failure + + USERID
}
Start rsync with System
#chkconfig rsync on

2. Configure/etc/rsyncd.conf (manual generation required)
Rsyncd.conf's parameter is written on the top of the global parameter and is written in the module is the module parameter
#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 password file permissions
Port = 873//Default ports 873

Module parameters
[Backup]//Here is the Certified module name, which needs to be specified on the client side
Path =/home/backup///need to do mirror directory, indispensable!
Comment = This is a test//This module's annotation information
Ignore errors//can ignore some irrelevant IO errors
Read Only = yes//reading only
List = no//no column files allowed
Auth users = hening//authenticated username, if this line is not indicated to be anonymous, this user has nothing to do with the system
Secrets file =/etc/rsync.pas//password and user name comparison table, password files generated by themselves
Hosts allow = 192.168.1.1,10.10.10.10//Allow host
Hosts deny = 0.0.0.0/0//Disable host
#transfer logging = yes
Note: The following green files are files that are automatically generated after you install the Rsync service
PID file = location where/var/run/rsyncd.pid//pid files are stored
Lock file = storage location for/var/run/rsync.lock//Lock files
Log file = location of/var/log/rsyncd.log//Log records

3, configure the rsync password (in the top of the configuration file has been written in the path)/etc/rsync.pas (name casually write, as long as the same as the above configuration file), format (a line of users)
Account Number: Password
#vi/etc/rsync.pas
Example:
hening:111111
Permissions: Because Rsync.pas stores the user name and password for the rsync service, it is important. To set the Rsync.pas to root, and the permission is 600.
#cd/etc
#chown Root.root Rsync.pas
#chmod Rsync.pas
3.RSYNCD.MOTD (Configuration welcome information, optional)
# VI/ETC/RSYNCD.MOTD
RSYNCD.MOTD records the welcome information for the Rsync service, where you can enter any textual information, such as:
Welcome to use the rsync services!
4, let the configuration effective
#service xinetd Restart

Third, start rsync server

Two ways to start an rsync server
1, start rsync Server (Independent launch)
#/usr/bin/rsync–daemon
2, Start rsync server (with XINETD super process startup)
#/etc/rc.d/init.d/xinetd Reload

Four: Join rc.local

In various operating systems, RC file storage location is not the same, you can modify the system to start when the rsync--daemon loaded in.
#vi/etc/rc.local
Join a line/usr/bin/rsync--daemon

Five Check rsync

#netstat-A | grep rsync
TCP 0 0 0.0.0.0:873 0.0.0.0:* LISTEN

Six. Configure Rsync Client

1, set the password
#vi/etc/rsync.pas
111111
Modify Permissions
#cd/etc
#chown Root.root Rsync.pas
#chmod Rsync.pas
2. Client Connection Server
Fetching files from the server
/USR/BIN/RSYNC-VZRTOPG--progress--delete hening@192.168.0.217::backup/home/backup--password-file=/etc/rsync.pas
Uploading files to the server side
/USR/BIN/RSYNC-VZRTOPG--progress--password-file=/root/rsync.pas/home/backup Hening@192.168.0.217::backup
This command backs up all files (including subdirectories) in the local machine/home/backup directory to the set backup directory of the backup module of the rsync SERVER (172.20.0.6).
Note that if the path ends with a "/", it means that the contents of the directory are backed up, but the directory is not created, such as without "/".
Rsync usage:
rsync [OPTION] ... [user@] HOST::SRC [DEST] #从RSYNC server backup files to local machine
rsync [OPTION] ...      src [src] ... [user@] HOST::D est #从本地机器备份文件到RSYNC SERVER
3. Automatic operation
1) vi/usr/local/rsync/time.sh//Making script files
Copy the contents below.
#!/bin/bash
/USR/BIN/RSYNC-VZRTOPG--progress--delete hening@192.168.0.217::backup/home/backup--password-file=/etc/rsync.pas
2) crontab-e
Add * * * * */usr/local/rsync/time.sh//time.sh script file every 55 minutes
Five iptables
Iptables-a input-p tcp-s! 11.22.33.44--dport 873-j DROP
So, only 11.22.33.44 this client IP can access this rsync server.
Command introduction:-rvlhpogdts
rsync command Parameters
-V indicates verbose detail display
-Z indicates compression
-R indicates recursive recursion
-T indicates keeping the original file creation time
-O indicates retention of original file owner
-P indicates keeping parameters of the original file
-G to maintain the group that the original file belongs to
-A archive mode
-P represents an option feature that replaces-partial and-progress
-e SSH establishes an encrypted connection.
--partial prevents rsync from deleting the copied portion of a transmission outage (if the transfer is interrupted during the copying of the file, the default action for Rsync is to undo the previous action, that is, from the target
Deletes part of a file that has been copied. )
--progress means showing detailed progress.
--delete means that if the server side deletes this file, then the client also deletes the file accordingly, maintaining true consistency.
--exclude does not contain/ins directory
--size-only This parameter is used in two folders only if there are some new files in the source folder, there are no duplicate files and have been modified, because the file may be skipped because the content is modified to the same size. This parameter can greatly improve the efficiency of synchronization because it does not need to check that the contents of the file with the same name are the same.
--password-file to specify a password file that contains the password for the server-side specified authenticated user.
This allows you to use it in a script without having to enter the authentication password interactively, but note that this password file permission attribute must be set to only the master readable.
Hening@192.168.0.217::backup
Hening refers to the server-side designated authenticated user
192.168.0.217 refers to the server-side IP
:: Backup indicates the name of the module on the server side that needs to be synchronized;
/home/quack/backup/$DATE is the synchronized file refers to the directory address that is stored on this computer.
/var/log/rsync. $DATE is the directory address that is stored on the local computer after the synchronized log file.
Attention
Do not put/then the directory name also contains mirror, put/then only the contents of the things mirror
Example Summary process:
1. Configure the main control side
# vim/etc/rsyncd.conf
###################################
UID = nobody
GID = Nobody
Use chroot = no
Max connections = 4
stirict modes = yes
Port = 873
[Backup]
Path =/usr/local/test/
Comment = This is a test
Ignore errors
Read Only = False
List = no
Hosts allow = 192.168.0.11
Hosts Deny = 0.0.0.0/0
Auth users = Bakweb
Secrets File =/etc/rsyncd.pw
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
Log file =/var/log/rsyncd.log
###################################
# VIM/ETC/RSYNCD.PW
###################################
bakweb:123456
###################################
# CD/ETC
# chown Root.root RSYNCD.PW
# chmod RSYNCD.PW
Start Rsync Server
# rsync--daemon
See if Port 873 is open
Join start
# echo "Rsync--daemon" >>/etc/rc.local
Write permissions to the/usr/local/test directory
# Chown-r Nobody.nobody/usr/local/test
# Chmod-r 770/usr/local/test
Master configuration Complete
2. Client Configuration
# VIM/ETC/RSYNCD.PW
####################################
123456
####################################
# chown ROOT.ROOT/ETC/RSYNCD.PW
# chmod 600/ETC/RSYNCD.PW
Using the command to update to the server data file directly does not require a password
RSYNC-VZRTOPG--progress--password-file=/etc/rsyncd.pw/usr/local/bin/bakweb@192.168.0.10::backup

Attention:

1. Here's the backup name of the main control conf configuration inside [backup], must have the same name
2.bakweb the main control conf configuration inside the Bakweb, you can name, not the system user

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.