Installation and configuration of linux rsync

  • 2020-05-06 12:10:41
  • OfStack

1. Installation: yum-y install rsync

2.vim /etc/xinetd.d/rsync


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 was created manually, not by default)

uid = nobody # backup in what capacity, user ID
gid = nobody # backup in what capacity, group ID
Note that this user ID and group ID can be set to root for convenience, so that rsync is almost
To read any files and directories, but also security concerns. It is recommended to set it to read only the directory and
that you are backing up A can.

use chroot = no
max connections = 0   # maximum number of connections, 0 means there is no limit to
port = 873                   # default port 873
pid file = / var/log/rsync/rsyncd pid     # running processes ID
wrote lock file = /var/log/rsync/rsync.lock
log file = / var/log/rsync/rsyncd log  
# log file motd file = / var/log/rsync/rsyncd motd  
# welcome news strict modes =yes               # whether to check the permissions of the password file
[www]                     # specifies the certified backup module name
uid = www1
gid = www1
path = /www/     # directory
that requires backup comment = BACKUP attachment                 # comment
ignore errors               # ignore some irrelevant IO errors
read only = false                   # is set to be non-read-only, that is, to be passed to the appropriate directory on the server.
list = false                     # do not allow column files
exclude = test/ test.php           hosts allow = all         # allows you to connect to the server's host IP address. If multiple ip,
is separated by a space hosts deny = 172.25.0.0/24   # disallow connection to the server's host IP address, which can also be *, for all.
auth users = backup           secrets file = /etc/ rsyncd.passwd         # authentication file name, used to store the password
[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 file
is to save the user account information Format: backup:password, permissions must be 600

5. Restart service: / 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. Plan 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 # synchronize
every 5 hours
the following is a supplement:

Installation system: redhat linux as 4 2.6.9
rsync is a data image backup tool under the unix system, which can be seen from the naming of the software --remote sync. It has the following features:
You can mirror and save entire directory trees and file systems.
It is easy to keep the permissions of the original file, the time, the soft and hard links, and so on.
No special privileges are required to install.
Optimized flow, high file transfer efficiency.
Files can be transferred using rcp, ssh, etc., or via a direct socket connection.
Supports anonymous transmission to facilitate site mirroring.
step
1. From the original site to download: [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, rsync is installed on both the client and server. The client runs rsync as a client, and the server runs rsync as a server, which listens on port 873.
3. Run rsync
/usr/local/bin/rsync --daemon
Verify successful startup:
netstat -na|grep 873
4. Configure rsync
Simple configuration: edit /etc/ rsyncd.conf file as follows:
Global configuration section
secrets file = /etc/ rsyncd.secrets authenticates the name and location of the username and password file
motd file = /etc/ rsyncd.motd welcome information file name and location (this file does not have, you can add)
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
Module configuration section
[web]
comment = web 's directory
path = /home/test/software
auth users = rsync
#secrets file = /etc/rsyncd.secrets
5. Generate verification file
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 plus -- password-file =/etc/rsyncd The above command transfers the files from the web module directory on server 10.4.5.161 to the native /china directory and removes the files from the native /china directory that are not in the directory specified by server 161 web module. To synchronize the directory files on both computers.


Related articles: