Linux/centos rsync Installation Configuration tutorial

Source: Internet
Author: User
Tags chmod command line readable ssh centos file permissions iptables rsync

First, server-side configuration:

# yum-y Install xinetd

# Vi/etc/xinetd.d/rsync

The following code

Service rsync


Disable = yes

Socket_type = Stream

wait = no

user = root

Server =/usr/bin/rsync

Server_args =–daemon

Log_on_failure + + USERID


Disable = yes change to disable = no

and start xinetd.

#/etc/init.d/xinetd Start or service xinetd restart

Note: If the server is equipped with a firewall, remember to open the port, the default port is 873

# telnet 873

Trying ...

Telnet:connect to address refused

# iptables-a input-s tcp-m tcp--dport 873-j ACCEPT

# iptables-a input-p tcp-m tcp--dport 873-j DROP

# vi/etc/rsyncd.conf (this file is created if it does not exist)

#Global Settings

UID = root #以什么身份运行rsync

GID = root

Use chroot = no #不使用chroot

Max connections = #最大连接数

Secrets file =/etc/rsyncd.secrets #密码文件位置, authentication files settings, setting user name and password

Log file =/var/log/rsyncd.log #指定rsync的日志文件, not sending logs to syslog

PID file =/var/run/ #指定rsync的pid文件

Lock file =/var/run/rsync.lock #指定支持max connections parameter, the default value is/var/run/rsyncd.lock

Comment = Hello World

#motd file =/etc/rsyncd.motd #欢迎信息文件名称和存放位置 (this file is not available and can be added by itself)

[Backup] # Here is the Certified module name, which needs to be specified on the client side

Path =/titan24/www/repos # A directory that needs to be mirrored

Auth users = rsync # Authorized account number. Authenticated username, if this line is not available, it indicates anonymity, multiple users, separated

Read Only = no # Yes reading value is no meaning is readable and writable mode, data recovery with no

Hosts allow = #允许访问的服务器IP

Hosts deny = * #黑名单

List = true # allows column files

#ignore errors # can ignore some irrelevant IO errors

#exclude = cache/111/cache/222/#忽略的目录

# Vi/etc/rsyncd.secrets (set access (authenticated) Username password)

rsync:111111 #用户名: Password

Correct permissions to the file

# chown Root:root/etc/rsyncd.secrets

# chmod 600/etc/rsyncd.secrets # (must be 600)

Second, the client side of the synchronization

The client defaults as if it had been installed in rsync, without the words installed:

# yum-y Install rsync

To perform an asynchronous synchronization operation:

/usr/bin/rsync-avz--progress rsync@

# crontab-e # (You can sync files every three minutes at timed time)

*/3 * * * * RSYNC-AVZ--progress rsync@

The following command is complete:


Add password


Note that the client's password file requires only a password and does not require a username!

To change file permissions:

#chmod 0600/etc/rsyncd.pas

#rsync-vzrtopgu--progress--delete--password-file=/etc/rsyncd.pas rsync_user@ /

The V in-VZRTOPG in this command line is verbose,

Z is a compressed transmission,

R is recursive,

TOPG are the parameters that keep the original attributes of the file, such as the owner and the time.

You are only synchronizing the files that have been updated, so that files that are not updated are updated once, but be aware of the synchronization of both machines ' clocks.

–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.

Later in the rsync_user@, the rsync_module_name1 is the module name, which is the custom name in/etc/rsyncd.conf, rsync_ User is the username specified in the specified module that can be synchronized.

The final/www is the backup to the local directory name.

In this case, you can also use the e-ssh parameter to establish an encrypted connection.

You can use –password-file=/password/path/file to specify a password file, so that it can be used in the script without having to enter the authentication password interactively, it should be noted that this password file permission attribute must be set to only the owner-readable.

#/usr/local/rsync/bin/rsync-vzrtopg–progress–delete rsync_user@


Or you can make password files.

Because of the need for system crontab execution, here is the way to read the password file,

This is the time to succeed.

Please continue to browse the next page: Sync command description

---------------------------------sync command Description:---------------------------------

1 Displaying directory Contents



A) rsync

b) rsync-r

c) rsync jack@

d) rsync ssh_user@

Command description


A) Display directory contents (first level)

b) recursive display of directory content

c) Displaying the contents of the remote host directory

* NOTE 1: Port mode, authentication based on rsync user

* Note the directory on the 2:rsync server must have XX7 permissions.

d) View the contents of the remote host directory

* Note 1:remote shell mode, authentication based on system local user via SSH connection

* NOTE 2: This only uses a colon (:), while the user name is the remote host SSH user, the password is the SSH user's corresponding password.

* Note 3: Use "" To list information about the folder itself. To list the contents of a folder, you should use "/".

Parameter description


-R recursive operation of the directory

2 Sync between local directories



a) rsync-av–progress/* * * ATTENTION (/) * * *

b) rsync-av–progress

c) Rsync-avu–progress–delete/

D) rsync-av–progress–temp-dir=/tmp/

Command description


A) Synchronize all files in the Src-dir directory to the Dst-dir directory

b Synchronize all files in the Src-dir directory to the Dst-dir/src-dir directory

c) The content of the Src-dir directory to the Dst-dir directory for differential updates, there are additions/updates to add replacement, there is a reduction in the deletion

D) More than a –temp-dir=/tmp, that is, specify/tmp as a temporary swap area, so as to avoid errors due to insufficient target directory space caused by the inability to sync files.

Parameter description


-A is equivalent to the-rlptgod set

-U is equivalent to –update and is not updated when the target file is newer than the source file

-V Display synchronized files

–progress percentage progress, transfer rate when file synchronization is displayed

–delete Delete files in the destination directory more than the source directory

3 Synchronization between remote hosts



A) rsync-avz–progress jack@

b) Rsync-avz–progress Jack@–password-file=/home/jack/rsync.jack

c) Rsync-avuz–progress–delete Jack@–password-file=/home/jack/rsync.jack

d) rsync-avz–progress jack@

Command description


A to synchronize the contents of the local directory to the remote host directory, Jack is an rsync database user (see 3/etc/rsync.secrets)

(b) Synchronization of non-interactive logon files by automatically reading user passwords

c) more than B-U and –delete

d Synchronize remote host content to local directory

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.