Rsync: a very practical file synchronization command, rsync is very practical
Sync is a file synchronization and data transmission tool in Linux. It can be used to synchronize files and release code.
1. install.
Yum install-y xinetd
Yum insatll-y rsync
2. Configuration
Enable rsync vim/etc/xinetd. d/rsync
Service rsync {disable = no # change yes to no flags = IPv6 socket_type = stream wait = no user = root server =/usr/bin/rsync server_args = -- daemon log_on_failure + = USERID}
Edit master configuration file
Vim/etc/rsyncd. conf Server
Uid = nobody # The owner Group of the directory or file is nobody. During synchronization, an error is reported, indicating that the user group of the directory file is not authorized.
Gid = nobody
Use chroot = yes
Max connections = 30
Pid file =/var/run/rsyncd. pid
Log file =/var/log/rsyncd. log
List = no
[Data] # synchronization item module [the synchronization item does not need to be added on the server side]
Path =/usr/local/hero_all_backup/
Hosts allow = 192.168.50.146
Read only = yes
Start. Rsync-daemon
3. Use.
Rsync-avz aaa.txt 192.168.0.162: data
####
-V,-verbose detailed mode output
-A,-archive mode, indicating that the file is transmitted recursively and all file attributes are kept
-Z: compresses the backup files during transmission.
-- Delete: delete the files that are not in the SRC file in DST.
-- Exclude = specifies to exclude the file mode that does not need to be transferred.
4. Others.
Rsync-avz -- delete/tmp/2 // var/spool/clientmqueue/
Synchronize the useless files in the/tmp/2 empty directory to the/var/spool/clientmqueue/directory.
Rsync-avz -- delete -- exclude = ". svn" -- exclude = "*. swp"
Exclude hidden files of. svn and. swp during synchronization.