Common rsync options-A: Archive mode, equivalent to-rlptgod-V: Display Synchronization Process details-Z: Enable compression during transmission-H: retain the hard connection file-: preserve the ACL attribute information of a file -- delete: delete a file with a target but no source -- checksum: determines whether to synchronize the file based on the checksum.
1. Release rsync-daemon sharing 1) create a synchronization account file (not required if anonymous) [[email protected] ~] # Vim/etc/rsyncd_users.dbruser: 123456 // one user record per row othername: 123456 ...... [[Email protected] ~] # Chmod 600/etc/rsyncd_users.db // The permission must be strict; otherwise, synchronization will fail.
2) create/etc/rsyncd. conf sharing settings
[[Email protected] ~] # Vim/etc/rsyncd. confuid = nobodygid = nobodyuse chroot = yeslog file =/var/log/rsyncd. logpid file =/var/run/rsyncd. PID [tools] Path =/usr/src comment = rsync share test read only = Yes dont compress = *. GZ *. bz2 *. tgz *. zip // applicable to various compressed files auth users = ruser // who is allowed to access secrets file =/etc/rsyncd_users.db // specify the path of the account file
2. upload and download of rsync + rsync servers
[[Email protected] ~] # Rsync // browse Shared Password: // verify password drwxr-XR-x 4096 2009/10/01 22:58:39 debugdrwxr-XR-x 4096 2009/10/01 22:58:39 kernels... [[email protected] ~] # Mkdir/root/mysrc [[email protected] ~] # Rsync-avz -- delete/root/mysrc // downstream synchronization to delete unnecessary files
3. Rsync real-time synchronization (inotify monitoring and triggering)
1) install the inotify-tools software package
[[Email protected] ~] # Tar zxf inotify-tools-3.13.tar.gz [[email protected] ~] # Cd inotify-tools-3.13 [[email protected] inotify-tools-3.13] #./configure... [[email protected] ~] # Make & make install2). inotifywait tool trigger Verification
Take the monitoring/root directory as an example. When the documents under the/root directory change, the corresponding prompt [email protected] ~] is immediately displayed. # Inotifywait-mrq-e modify, move, create, delete, attrib/root/create, isdir tdir1/root/create file1.txt/root/modify file1.txt/root/delete file1.txt
Rsync remote Synchronization Service