Rsync file parameters for Synchronous backup servers

Source: Internet
Author: User
Tags connection reset

I just got in touch with the rsync synchronization Backup Server File software. I am looking for an rsync parameter description today. I will introduce these parameters to you. I hope they will help you.

Rsync Installation

The latest version of rsync is 3.0.9.

Wget http://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gz tar-xvzf rsync-3.0.9.tar.gz; cd rsync-3.0.9;./configure; make install

Rsync server configuration
1.
Vi/etc/rsyncd. conf (manually generated)

The parameters of rsyncd. conf are written on the top as global parameters, and the parameters of modules are written on the top.

# Uid = root for the user who runs the RSYNC daemon # gid = root for the group that runs the RSYNC daemon # Do not use chroot = no # the maximum number of connections is 4 max connections = 4 # pid File storage location pid file =/var/run/rsyncd. pid # lock file storage location lock file =/var/run/rsync. lock # log file storage location =/var/log/rsyncd. log [logs] # directory to be synchronized path =/usr/local/lnmp # ignore irrelevant IO errors ignore errors # Read-only, cannot upload read only = true # list of prohibited files = false # ip addresses that are allowed to access the service # hosts allow = 192.168.1.200 # ip addresses that are not allowed to access the service # hosts d Eny = 0.0.0.0/32 # authenticated user name, which must exist in the system, but the password must be configured in secrets file, not the system password. Auth users = root # authenticate the User Password file and configure the password secrets file for auth users =/etc/backserver. pas

2.
The rsync password file is in clear text separated by colons.

Each user has a row, followed by the user name and password, and the user must be a user existing in the operating system.

The owner of the file must be root and the permission is 600.

Vi/etc/backserver. pas, add

Root: 123456

Save and exit and run

Chown root: root/etc/backserver. pas chmod 600/etc/backserver. pas

3.
Start rsync

/Usr/local/bin/rsync -- daemon

4.
Check whether the process exists,

Ps-aux | grep rsyncroot 4406 0.0 0.0 4228 588? Ss May14/usr/local/bin/rsync -- daemon netstat-an | grep 873 tcp 0 0 0.0.0.0: 873 0.0.0.0: * LISTEN

The preceding result indicates that the rsync server has been started.

5.
Open Firewall

Iptables-I INPUT-p tcp -- dport 873-j ACCEPT
Iptables-L
The result is as follows:
Chain INPUT (policy ACCEPT)
Target prot opt source destination
ACCEPT tcp -- anywhere tcp dpt: rsync

6.
End Process: kill-9 pid Value
Kill-15 process name

7.
Rsync boot
Echo "/usr/bin/rsync -- daemon">/etc/rc. local

(Start rsync automatically at startup)

Notes
1) The system prompts that the password file cannot be read. If you need to manually enter the password, it may be that the password file permission is not 600, the format is incorrect, or the path is incorrect.
2) If you are prompted to create a new directory or file transfer fails, it may be because the directory you want to synchronize has no permission. You 'd better change the permission of the directory you want to synchronize to 744.
3) When Synchronizing files from the client to the server, it is best to transfer a single file directory; otherwise, errors may occur.

Rsync client Configuration

1.
You can directly use the rsync command without configuring the client,

Rsync-vzrtopg -- progress -- delete root@118.244.216.177: logs/data/lnmp

2.
If you want to log on to rsync without a password, you only need to configure the password file on the client.

Vim/etc/rsyncd. secretes. This file only contains the server-side auth user password and does not need to be configured with the user name.
123456
Chmod 600 rsyncd. secretes (the Password File Permission is 600, which must be set in this step)

Note: The password must be consistent with the password in the rsync server password file. The password of the rsync client should also be used.

Rsync-vzrtopg -- progress -- delete -- password-file =/etc/rsyncd. secretes root@118.244.216.177: logs/data/lnmp

Note: The above commands are used to synchronize files in the server path (/usr/local/lnmp) to the client path (/data/lnmp.

If you want to synchronize the client files to the server, it is as follows:
Rsync-vzrtopg -- progress -- delete -- password-file =/etc/rsyncd. secretes/data/lnmp root@118.244.216.177: logs

3.
Rsync scheduled task

Execute rsync backup at AM

Crontab-e
00 04 *** rsync-vzrtopg -- progress -- delete -- password-file =/etc/rsyncd. secretes root@118.244.216.177: logs/data/lnmp

4.
Rsync synchronization Parameters
-In vzrtopg, v is verbose, z is compression, r is recursive, and topg is a parameter that maintains the original file attributes, such as owner and time.
-- Progress indicates that the detailed progress is displayed.
-- Delete: if the server deletes the file, the client also deletes the file.
Root in root@xxx.xxx.xxx.xxx is the user name in the specified password file, xxx is the IP address
Logs refers to the module name defined in rsyncd. conf.
/Data/lnmp refers to the local directory to be backed up

5.
Common rsync parameters:
# Rsync [option] Destination path of the Source Path
[Option:
A: Use the archive mode, which is equal to-rlptgoD, that is, keep the original file permission.
Z: Indicates compressed data during transmission.
V: display to the screen
E: Use a remote shell program (rsh or ssh can be used)
-Delete: Precisely saves copies. files deleted from the source host are also deleted from the target host.
-Include = PATTERN: do not exclude files or directories conforming to PATTERN
-Exclude = PATTERN: exclude all files or directories that conform to the PATTERN.
-Password-file: Specifies the password used for rsync server user authentication.

--------------------------------------------------------
Rsync Common Errors
1.
Rsync: failed to connect to 118.244.216.177: No route to host (113)
Rsync error: error in socket IO (code 10) at clientserver. c (124) [handler ER = 3.0.6]
Cause: the firewall shields the port.
Solution: Open Section 873
Iptables-I INPUT-p tcp -- dport 873-j ACCEPT
Iptables-L
If the preceding commands do not work, you can directly stop the firewall.
/Etc/init. d/iptables stop

2.
@ ERROR: auth failed on module backup
Rsync error: error starting client-server protocol (code 5) at main. c (1506) [runner ER = 3.0.7]
It is estimated that the password file has no permissions set: chmod 600/home/admin/security/rsync. pass
It should be enough.

3. @ ERROR: auth failed on module xxxxx
Rsync: connection unexpectedly closed (90 bytes read so far)
Rsync error: error in rsync protocol data stream (code 12) at I/O. c (150)
This is because the password is set incorrectly and cannot be successfully logged in. Please check the password in rsyncd. scrt. Are the two sides consistent?

4. password file must not be other-accessible
Continuing without password file
Password:
This indicates that the File Permission attribute of rsyncd. scrt is incorrect. It should be set to 600.

5. @ ERROR: chroot failed
Rsync: connection unexpectedly closed (75 bytes read so far)
Rsync error: error in rsync protocol data stream (code 12) at I/O. c (150)
This is usually because the directory set by path in your rsyncd. conf does not exist. Please use mkdir to open the directory to be backed up

6. @ ERROR: access denied to www from unknown (192.168.1.123)
Rsync: connection unexpectedly closed (0 bytes encoded Ed so far) [Cycler]
Rsync error: error in rsync protocol data stream (code 12) at I/O. c (359)
The final reason is finally found. Because there are two network segments that need to be synchronized to the folder, but no other IP segment is added after hosts allow
Hosts allow = 192.168.1.0/24
Change
Hosts allow = 192.168.1.0/24 192.168.2.0/24
Restart the rsync service to solve the problem.

7. @ ERROR: auth failed on module backup
Rsync error: error starting client-server protocol (code 5) at main. c (1506) [runner ER = 3.0.7]
The file/etc/rsync. pas is not set on the client, but the parameter -- password-file =/etc/rsync. scrt is added when the rsync command is used.

8. rsync: recv_generator: mkdir "/teacherclubBackup/rsync ...... "Failed: No space left on device (28)
* ** Skipping any contents from this failed directory ***
The disk space is full.

9. rsync: opendir "/kexue" (in dtsChannel) failed: Permission denied (13)
The permission settings for the synchronization directory are incorrect. The value is changed to 755.

10. rsync: read error: Connection reset by peers (104)
Rsync error: error in rsync protocol data stream (code 12) at io. c (759) [runner ER = 3.0.5]
The xinetd daemon is not started.
[Root @ CC02/] # service xinetd start

11. rsync: unable to open configuration file "/etc/rsyncd. conf": No such file or directory
The default location of the configuration file for xnetid search is/etc, and the rsyncd. conf file cannot be found in/etc.

12. rsync: failed to connect to 203.100.192.66: Connection timed out (110)
Rsync error: error in socket IO (code 10) at clientserver. c (124) [handler ER = 3.0.5]
Connection to the server timed out, check the server port netstat-tunlp, remote telnet Test

13. What ports do I need to open on the firewall to adapt to rsync?
Depends on the situation. Rsync can directly transfer files through tcp connection on port 873, or through ssh on port 22, but you can also change the port through the following command:
Rsync -- port 8730 otherhost ::
Or
Rsync-e 'ssh-p 2002 'otherhost:

14. How can I copy only the directory structure through rsync and ignore the file?
Rsync-av -- include '*/' -- exclude '* 'source-dir dest-dir

15. Why do I always see the "Read-only file system" error?
Check if you forget to set "read only = no"

16. @ ERROR: chroot failed
Rsync error: error starting client-server protocol (code 5) at main. c (1522) [runner ER = 3.0.3]
Cause:
The directory on the server does not exist or has no permissions. Creating a directory and correcting permissions can solve the problem.

17. @ ERROR: auth failed on module tee
Rsync error: error starting client-server protocol (code 5) at main. c (1522) [runner ER = 3.0.3]
Cause:
On the server side, this module (tee) needs to verify the user name and password, but the client does not provide the correct user name and password. Authentication fails. Provide the correct username and password to solve this problem.

18. @ ERROR: Unknown module 'TEE _ nonexists'
Rsync error: error starting client-server protocol (code 5) at main. c (1522) [runner ER = 3.0.3]
Cause:
The specified module does not exist on the server. Provide the correct module name or modify it on the server to the module you want to solve the problem.

19. The permission cannot be copied. Remove the synchronization permission parameter. (This is usually the case when Linux is switched to Windows)

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.