Installation and configuration of Linux rsync _linux

Source: Internet
Author: User
Tags anonymous auth chmod file permissions rsync

1. Installation: Yum-y Install rsync

2.vim/etc/xinetd.d/rsync

Copy Code code as follows:

Service rsync
{
Disable = no
Socket_type = Stream
wait = no
user = root
Server =/usr/bin/rsync
Server_args =–daemon
Log_on_failure + + USERID
}

3.vim/etc/rsyncd.conf (this file is created manually, default does not)

UID = Nobody # Backup in what capacity, User ID
GID = Nobody # Backup in what capacity, group ID
#注意这个用户ID和组ID, if it's convenient, you can set it to root so that rsync can almost
#以读取任何文件和目录了, but it also poses a security risk. Recommended to read only the directories and text you want to back up
Pieces can be.

Use chroot = no
Max connections = 0 #最大连接数, 0 represents no Limit
#port = 873 #默认端口873
PID file =/var/log/rsync/rsyncd.pid #运行进程的ID写到哪里
Lock file =/var/log/rsync/rsync.lock
Log file =/var/log/rsync/rsyncd.log #日志记录文件
MOTD file =/var/log/rsync/rsyncd.motd #欢迎消息
Strict modes =yes #是否检查口令文件的权限
[www] # Specify a certified Backup module name
UID = WWW1
GID = WWW1
Path =/www/# The directory to be backed up
Comment = BACKUP Attachment # comment
Ignore errors # Ignores some irrelevant IO errors
Read Only = False # is set to not read-only, that is, it can be passed to the appropriate directory on the server.
List = False # does not allow column files
#exclude = test/test.php #设置不同步的目录或文件用空格隔开
Hosts allow = All #允许连接服务器的主机IP地址, if more than one IP is separated by a space
Hosts deny = 172.25.0.0/24 #禁止连接服务器的主机IP地址 or *, which means all.
Auth users = backup # authenticated username, if this line is not found, it is anonymous
Secrets file =/etc/rsyncd.passwd # Authentication file name, used to store passwords
[WWW1]
Path =/www1/
Ignore errors
Read Only = True
List = False
Hosts allow = 202.99.11.121
Hosts Deny = 0.0.0.0/32
Auth users = Backup
Secrets file =/etc/rsyncd.passwd

4./ETC/RSYNCD.PASSWD is the file that holds the user account information
Format: Backup:password, permission must be 600

5. Service Restart:/usr/bin/rsync–daemon–config=/etc/rsyncd.conf

6. Client synchronization:
Rsync-vzrtopg–delete–progress Backup@192.168.18.200::www1/backup/www1–password-file=/etc/rsyncd.password

7. Planning Tasks
vim/opt/rsyncd.sh
Rsync-vzrtopg–delete–progress Backup@192.168.18.200::www1/backup/www1–password-file=/etc/rsyncd.password
chmod u+x/opt/rsyncd.sh
Crontab-e
0 5 * * * sh/opt/rsyncd.sh# sync once every 5 hours

The following are supplementary:

Installation system: Redhat Linux as 4 2.6.9
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.
Step
1. Download from the original website: [Url]http://rsync.samba.org/ftp/rsync/[/url]
2.[root@localhost bin]#./configure
[Root@localhost bin] #make
[Root@localhost bin] #make Install
Note that both the client and the server have to install rsync. The client runs rsync on a client side, and the server runs rsync as a server, which listens on port 873.
3. Run rsync
/usr/local/bin/rsync--daemon
Verify that the startup is successful:
Netstat-na|grep 873
4. Configure Rsync
Simple configuration: Edit the/etc/rsyncd.conf file as follows:
#全局配置部分
Secrets file =/etc/rsyncd.secrets Authentication user name and password file name and location
MOTD filename =/etc/rsyncd.motd Welcome information file name and location (this file is not available, you can add it yourself)
Read Only = yes
List = yes
UID = root
GID = root
#hosts allow = 10.4.5.213
#hosts deny = 10.4.5.0/24
Use chroot = no
Max connections = 5
Log file =/var/log/rsyncd.log
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
#模块配置部分
[web]
Comment = Web ' s directory
Path =/home/test/software
Auth users = rsync
#secrets file =/etc/rsyncd.secrets
5. Generate Certification Documents
echo "Rsync:rsync_password" >>/etc/rsyncd.secrets
chmod 600/etc/rsyncd.secrets
6. Synchronizing files on the server at the client server
RSYNC-VZRTOPG--delete--progress rsync@10.4.5.161::web/china/
Or add the--password-file=/etc/rsyncd.secrets option
The above command transfers files from the directory in the Web module on the 10.4.5.161 server to the native/china directory and deletes files in the native/china directory that are not in the directory specified in the 161 Server Web module. To synchronize the directory files of the two computers.

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.