Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure rsync in linux

2025-02-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of how to install and configure rsync in linux, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this article on how to install and configure rsync in linux. Let's take a look.

1. Installation: yum-y install rsync

2.vim / etc/xinetd.d/rsync

The copy code is 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 and is not available by default)

Uid = nobody # in what identity is the backup performed, user id

Gid = nobody # what is the identity of the backup, group id

# Note the user id and group id. If it is convenient, you can set it to root, so that rsync is almost available.

# to read any files and directories, but it also brings security risks. It is recommended that you can only read the directories and texts that you want to back up.

One piece will be fine.

Use chroot = no

Max connections = 0 # maximum number of connections, 0 means no limit

# port = 873 # default port 873

Pid file = / var/log/rsync/rsyncd.pid # where to write the id of the running process

Lock file = / var/log/rsync/rsync.lock

Log file = / var/log/rsync/rsyncd.log # logging file

Motd file = / var/log/rsync/rsyncd.motd # Welcome message

Strict modes = yes # whether to check the permissions of the password file

[www] # specify the name of the certified backup module

Uid = www1

Gid = www1

Path = / www/ # directories 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 transferred to the appropriate directory of the server.

List = false # column files are not allowed

# exclude = test/ test.php # set unsynchronized directories or files to be separated by spaces

Hosts allow = all # allows the ip address of the host to connect to the server, separated by spaces if multiple ip

Hosts deny = 172.25.0.0 hosts deny 24 # forbids connecting to the server's host ip address, which can also be *, indicating all.

Auth users = backup # authenticated user name. If there is no such line, 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.0amp 32

Auth users = backup

Secrets file = / etc/rsyncd.passwd

4./etc/rsyncd.passwd is a file that saves 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. Schedule a task

Vim / opt/rsyncd.sh

Rsync-vzrtopg-delete-progress backup@192.168.18.200::www1 / backup/www1-password-file=/etc/rsyncd.password

Chmod uplix / opt/rsyncd.sh

Crontab-e

0 5 * sh / opt/rsyncd.sh# synchronizes every 5 hours

The following is a supplement:

Install the system: redhat linux as 4 2.6.9

Rsync is a data mirror backup tool under a unix-like system, which can be seen from the name of the software-remote sync. Its features are as follows:

You can mirror and save the entire directory tree and file system.

You can easily maintain the permissions, time, soft and hard links of the original file, and so on.

It can be installed without special permission.

The optimized process has high file transfer efficiency.

You can use rcp, ssh, and so on to transfer files, or you can use a direct socket connection.

Anonymous transmission is supported to facilitate website mirroring.

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

To be clear, both the client and the server need to install rsync. The client runs rsync in client mode, and the server runs rsync in server mode, which listens on port 873.

3. Run rsync

/ usr/local/bin/rsync-- daemon

Verify that the startup was successful:

Netstat-na | grep 873

4. Configure rsync

Simple configuration: edit / etc/rsyncd.conf file as follows:

# Global configuration section

Secrets file = / etc/rsyncd.secrets authentication username and password file name and location

Motd file = / 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.0Comp24

Use chroot = no

Max connections = 5

Log file = / var/log/rsyncd.log

Pid file = / var/run/rsyncd.pid

Lock file = / var/run/rsync.lock

# Module configuration

[web]

Comment = web's directory

Path = / home/test/software

Auth users = rsync

# secrets file = / etc/rsyncd.secrets

5. Generate verification documents

Echo "rsync:rsync_password" > > / etc/rsyncd.secrets

Chmod 600 / etc/rsyncd.secrets

6. Synchronize files on the server on the client server

Rsync-vzrtopg-delete-progress rsync@10.4.5.161::web / china/

Or add-- password-file=/etc/rsyncd.secrets option

The above command transfers the files from the directory in the web module on the 10.4.5.161 server to the native / china directory and deletes the files in the native / china directory that are not in the directory specified by the server web module. To synchronize the directory files of the two computers.

This is the end of the article on "how to install and configure rsync in linux". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to install and configure rsync in linux". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report