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