Rsync server Construction

Source: Internet
Author: User

Rsync Introduction

Rsync is a file synchronization and transmission tool in UNIX systems.

It has the following features:

1. Update the entire directory and tree and File System

2. selectively preserve symbolic links, hard links, files belonging to, permissions, devices, and time

And so on

3. There are no special permission requirements for installation.

4. For multiple files, the internal pipeline reduces the latency of file waiting.

5. Use RSH, ssh, or direct port as the transfer port

6. supports anonymous rsync file synchronization, which is an ideal image tool;

 

Rsync serverThe server that runs the rsync service in deamon mode. You need to enable rsync deamon and start the xinetd service. The default port is 873.

 

Rsync ClientIs the server that initiates the rsync connection. Install rsync.

Rsync scenarios

After the rsync client initiates a connection, the rsync server checks whether the rsync client submits the built-in account name and password of the rsync server correctly. If the authentication is detected, file transmission starts, the transfer process is to first compare the file size, attributes, permissions, MD5 values, and other information as required. If the file information on both ends is inconsistent, synchronize the different file blocks as required.

The following uses the/usr/local/tomcat6/web directory of the backup rsync server as an example for deployment.

Rsync is easy to set up. Rsync is installed in most versions of UNIX, Linux, and even by default.

The global configuration file/etc/rsyncd. conf sometimes does not have this file after installation. You do not have to worry about creating one yourself. This file may not exist by default.

 

 

Rsync server setup steps:

1. Install rsync software (omitted)

2. Enable rsync deamon's xinetd service

# Chkconfig xinetd on open the xinetd startup Item (enter the command, if the system does not report an error)

# Chkconfig rsync on open the rsync startup Item (enter the command, if the system does not report an error)

# Vi/etc/xinetd. d/rsync check whether the configuration file is correct

The file content is as follows:

# Default: Off

# Description: the rsync server is a good addition

To an FTP server, as it \

# Allows CRC checksumming etc.

Service rsync

{

Disable = No

Socket_type = stream

Wait = No

User = root

Server =/usr/bin/rsync

Server_args = daemon

Log_on_failure + = userid

}

3. Configure rsync

# Vi/etc/rsyncd. conf set the rsync configuration file (new file)

Add the following content

Uid = nobody

Gid = nobody

Max connetctions = 4

Use chroot = No

Log File =/var/log/rsyncd. Log

Transfer logging = Yes

Log format = % T % A % m % F % B

PID file =/var/run/rsyncd. PID

Lock file =/var/run/rsyncd. Lock

# Auth users = root

Secrets file =/etc/rsyncd. pwd

[Web]

Path =/usr/local/tomcat6/Web

Comment = backup Web

Ignore errors

Read Only = Yes

List = No

Auth users = CMS

Secrets file =/etc/rsyncd. pwd

 

Configuration instructions:

Uid = nobody

Gid = nobody

UID and GID are built-in users of the system and must exist in the/etc/passwd file. The minimum permission is set here.

Max connetctions = 4

Max connections is the number of simultaneous connections on the client, in order to limit multi-thread synchronization.

Use chroot = No

Do not use chroot. If chroot is used, the root permission is required during synchronization, and the symbolic link files are excluded. Therefore, we do not use chroot.

Secrets file =/etc/rsyncd. pwdDefine Password FileRsyncd. pwd

 

[Web]

Set the Backup Task Name to web. The following are the Web Backup Task parameter settings until the end of another. We can create multiple backup tasks.

Path =/usr/local/tomcat6/WebDefine the directory to be backed up

Comment = backup WebDefinition display description, backup web directory

Ignore errorsIgnore synchronization errors

Read Only = YesDefine the access mode as read-only

List = NoIf the rsync client is defined, the directory structure cannot be listed.

Auth users = CMSDefines the user of the client backup web project. This user is a built-in rsync user and has nothing to do with the rsync server and the client system user.

 

4. Set the rsync built-in user and password

# Echo "CMS: cmscms">/etc/rsyncd. pwd

Here we set the rsync built-in user CMS and password cmscms.

Modify Password File Execution permission

# Chmod 600/etc/rsyncd. pwd

5. Restart the rsync service.

# Service xinetd restart start service

 

Rsync Client Setup steps

1. Install rsync software (omitted)

2. The client generates a Verification Certificate file.

# Echo "cmscms">/etc/rsyncd. pwd cmscms is the password

# Chmod 600/etc/rsyncd. pwd

3. Test

Run the following command to test whether the rsync client can synchronize with the rsync server:

#/Usr/bin/rsync-vzrtopg -- password-file =/etc/rsyncd. PWD -- Progress -- delete-after [email protected]: Web/usr/local/tomcat6/Web

/Usr/bin/Rsync is the rsync executable file path

-Vzrtopg -- password-file =/etc/rsyncd. pwd -- Progress -- delete-after synchronization Parameter

[Email protected]: Web indicates that the client synchronizes data with a CMS user, 100.1.1.147 indicates the IP address of the rsync server, and Web indicates the @ Web backup task on the rsync server.

/Usr/local/tomcat6/web is the location where the client stores the backup files.

 

 

 

Rsync Parameters

V,

Verbose

Verbose output

Q,

Quiet

Simplified output mode

C,

Checksum

Turn on the verification switch to force file transfer verification

A,

Archive

Archive mode: Transfers files recursively and keeps all files

Is equal to rlptgod.

R,

Recursive

Process subdirectories in recursive Mode

R,

Relative

Use relative path information

Rsync Foo/BAR/Foo. c remote:/tmp/

Create the foo. c file in the/tmp directory

Parameters:

Rsync R

Foo/BAR/Foo. c remote:/tmp/

The file/tmp/Foo/BAR/Foo. C will be created, that is, the full path information will be maintained.

B,

Backup

Create a backup, that is, if the target already has the same file name, rename the old file ~ Filename. You can use the suffix option to specify different backup file prefixes.

Backupdir

Back up the file (for example ~ Filename) is stored in the directory.

Suffix =

Suffix defines the backup file prefix

U,

Update

Update only, that is, skip all existing in DST and

And the file time is later than the file to be backed up. (Do not overwrite the updated file)

L,

Links

Retain soft links

L,

Copylinks

Process soft links like regular files

Copyunsafelinks

Just copy the link other than the SRC path directory tree

Safelinks

Ignore links other than the directory tree pointing to the SRC path

H,

Hardlinks

Retained hard links

P,

Perms

Maintain File Permissions

O,

Owner

Maintain file owner information

G,

Group

Keep file group information

D,

Devices

Keep Device File Information

T,

Times

Preserve file time information

S,

Sparse

Special processing of sparse files to save DST Space

N,

Dryrun

What files will be transmitted in reality?

W,

Wholefile

Copy files without incremental Detection

X,

Onefilesystem

Do not span file system boundaries

B,

Blocksize =

Size indicates the block size used by the algorithm. The default value is 700 bytes.

E,

Rsh =

Command specifies the shell program that replaces RSH

Rsyncpath =

Path specifies the path of the rsync command on the remote server

C,

Cvsexclude

Automatically ignores files in the same way as cvs for sorting

Except those files that do not want to be transmitted

Existing

Update only those files that already exist in DST, instead of backing up those new

Created File

Delete

Delete files not found in SRC in DST

Deleteexcluded

Delete Files specified by this option at the receiving end.

Deleteafter

Delete after transfer ends

Ignoreerrors

Delete Io errors in time

Maxdelete =

Num: delete a maximum of num files.

Partial

Retain files that are not completely transferred for any reason to accelerate subsequent re-transmission.

Force

Forcibly Delete the directory, even if it is not empty

Numericids

Do not match the number user and group ID as the user name and group name

Timeout =

Time IP timeout time, in seconds

I,

Ignoretimes

Do not skip files with the same time and length

Sizeonly

When determining whether to back up a file, you only need to check the file size, regardless of the file time.

Modifywindow =

Num determines whether the timestamp window of the file is used at the same time,

The default value is 0.

T

Tempdir =

Create a temporary file in Dir

Comparedest =

Dir also compares the files in Dir to determine whether backup is required.

P

Equivalent to partial

SS

Show backup process

Z,

Compress

Compressing backup files during transmission

Exclude =

Specify the pattern to exclude files that do not need to be transmitted.

Include =

Pattern specifies the file mode to be transmitted without exclusion

Excludefrom =

File: exclude files in the specified mode.

Includefrom =

File does not exclude files that match the specified file Mode

Version

Print Version Information

Address

Bind to a specific address

Config = file: specify other configuration files. The default rsyncd. conf is not used.

File

Port =

Port: specify other rsync service ports.

Blockingio

Block I/O for remote shell

Stats

Transmission status of some files

SS

Actual transmission process during transmission

Logformat =

Format specifies the log file format

Passwordfile = file get password from File

Bwlimit = kbps limits I/O bandwidth, Kbytes per second

H,

Help

Show Help Information

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.