Rsync Real-Time Synchronization

Source: Internet
Author: User
Tags inotify rsync

Rsync installed by default


Remote 192.168.1.123

Local 192.168.1.124


Rsync + SSH


Run

Rsync-Az [email protected]:/root/bak # directory

Rsync-Az [email protected]:/root // Bak # contents in the directory

Or

On the remote host

Rsync-Az/root [email protected]:/bak

Rsync-Az/root/[email protected]:/bak


Rsync client + rsync server


Server

Create a synchronization account file (not required if anonymous)

Echo "zongxuan: zongxuan">/etc/rsyncd_users.db

The permission must be strict; otherwise, synchronization will fail.

Chmod 600/etc/rsyncd_users.db

Create/etc/rsyncd. conf sharing settings

Uid = Nobody # specify this module to transmit files with the specified uid, and synchronize sensitive data to the root

Gid = Nobody # specify the module to transmit files with the specified GID.

Use chroot = Yes

Log File =/var/log/rsyncd. Log

PID file =/var/run/rsyncd. PID

[Zongxuan]

Path =/tmp

Comment = rsync Test

Read Only = Yes

Dont compress = *. GZ *. bz2 *. tgz *. Zip # No compression

Auth users = zongxuan

Secrets file =/etc/rsyncd_users.db # specify the path of the account file

Enable rsync-Daemon Service

Append to boot

Echo "/usr/local/bin/rsync -- daemon">/etc/rc. Local

Yum-y install xinetd

Chkconfig rsync on

Chkconfig xinetd on

Service xinetd restart



Client

Browsing and sharing

Rsync [email protected]: Tools

Synchronization

Mkdir/root/mysrc

Rsync-avz -- delete [email protected]: zongxuan/bak/# downstream synchronization, delete unnecessary files in mysrc


The client only needs to configure the password file.

# Cd/etc

Vim rsyncd. secretes


Echo "zongxuan">/etc/rsyncd. secretes

Chmod 600/etc/rsyncd. secretes

/Usr/bin/rsync -- avz -- password-file =/etc/rsyncd. secretes -- Progress [email protected]: zongxuan/bak/





Rsync real-time synchronization (inotify monitoring and triggering)


Tar zxf inotify-tools-3.13.tar.gz

CD inotify-tools-3.13

./Configure

Make & make install


Inotifywait-mrq-e modify, move, create, delete, attrib/My | while read x y z; /usr/bin/rsync -- avz -- password-file =/etc/rsyncd. secretes -- Progress


[Email protected]: zongxuan/bak/; done


This article is from the "romantic smile" blog. For more information, contact the author!

Rsync Real-Time Synchronization

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.