Rsync Server file synchronization Setup and use _ Server other

Source: Internet
Author: User
Tags socket file permissions rsync

Rsync is a data mirroring Backup tool under Unix-like systems that can mirror the entire directory tree and file system. And it is easy to maintain the original file permissions, time, soft and hard links and so on.

can be installed without special permissions.

Characteristics:

The full content is copied on a fast, first synchronization, but the next time he only passes the modified file and can compress and decompress during the transfer, so less bandwidth can be used.
Security, you can use the SCP, SSH and other ways to transfer files, of course, you can also through the direct socket link
Support for anonymous transmission to facilitate site mirroring.

First of all

Download installation package

Copy Code code as follows:

wget http://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gz
Tar zxvf rsync-3.0.9.tar.gz
CD rsync-3.0.9
./configure
Make
Make install

After installation, create a new sync profile

Copy Code code as follows:

Vim/etc/rsyncd.conf
Uid=www
Gid=www
Max connections=1000
Use Chroot=no
Log File=/var/log/rsyncd.log
PID File=/var/run/rsyncd.pid
Lock File=/var/run/rsyncd.lock

[Test]
path=/data0/htdocs/
Comment = www.test.com CDN src files
Ignore errors
Read Only = no
Hosts allow = 127.0.0.1 192.168.1.0/24 10.1.1.0/24
Hosts deny = *

Modify profile permissions and project directory permissions

Copy Code code as follows:

chmod 644/etc/rsyncd.conf
Chown Www.www/data0/htdocs

Open rsync

Copy Code code as follows:
Rsync--daemon

The server side is the same as the client configuration

Executing on the server side

Copy Code code as follows:
Rsync-rtuv--delete/data0/htdocs/10.1.1.195::test/

Synchronizes all files under the local/data0/htdocs/to the client 10.1.1.195 server's test module

Executing on the client

Copy Code code as follows:
RSYNC-VZRTOPG--delete--progress www@10.1.1.195::test/data0/htdocs/

Synchronize the contents of the test module under the remote server 10.1.1.195 to the local/data0/htdocs/

The-VZRTOPG on the command line above means:
-V represents verbose (verbose)
-Z = ZIP (compressed)
-R represents recursive (recursive directory)
-TOPG is a parameter that maintains the original properties of the file such as O=owner (owner), T=times (Time), p=perms (permissions), G=group (group)
-h means keep hard connections
-L: Retaining Soft links
-U: Represents a new file that updates only the source file more than the target time
--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.

Here are some of the mistakes that happen in the process

Rsync:error while loading shared libraries:libiconv.so.2:cannot open Shared object file:no such file or directory

Solution: Add a line in/etc/ld.so.conf/usr/local/lib run Ldconfig run rsync--daemon

Error reason: May have previously updated Iconv library, if you are not root, Ldconfig also can not run, the solution is, set the environment variable Ldflags=-l/usr/local/lib

rsync:failed to connect to 192.168.1.42 (192.168.1.42): No route to host (113)
Rsync error:error in Socket IO (code ten) at CLIENTSERVER.C (122) [sender=3.0.9]


WORKAROUND: You may be able to set rules to release rsync or directly shut down the firewall because the client or the server-side firewall is turned on to prevent communication.

There is also a possibility that you may be prompted for no permissions during the synchronization process

Solution: Look at the module synchronization directory permissions are set to the right, module directory permissions to be set to the UID and GID in the configuration file

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.