I. Introduction of RSYNC Tools
Rsync is a data-mirroring Backup tool under Unix-like systems, and--remote sync can be seen from the name of the software. Rsync is a file synchronization and data Transfer tool under the Linux system that uses the "rsync" algorithm to synchronize files between a client and a remote file server, or to back up data from one partition to another on the local system. If Rsync has a data transfer interruption during the backup process, it can continue to transmit the inconsistent portions after recovery. Rsync can perform full or incremental backups. Its main features are:
1. Can be mirrored to save the entire directory tree and file system;
2. It is easy to maintain the original file permissions, time, soft and hard links, without special permission to install;
3. Can synchronize data incrementally, file transfer efficiency is high, so synchronization time is short;
4. You can use RCP, ssh and other means to transfer files, of course, you can also through a direct socket connection;
5. Support anonymous transmission, in order to facilitate the site mirror image, etc.;
6. Encrypt transmission data, ensure the security of data;
Rsync-av/etc/passwd/tmp/0.txt
Rsync-av/tmp/0.txt 192.168.1.101:/tmp/1.txt
Format:
rsync [OPTION] ... SRC (source directory) DEST (destination directory)
rsync [OPTION] ... SRC [[Email protected]]host:dest
rsync [OPTION] ... [[Email Protected]]host:src DEST
rsync [OPTION] ... SRC [[Email protected]]host::D EST two colons
rsync [OPTION] ... [[Email Protected]]host::src DEST
Installing rsync
Synchronizing directories
Sync directly with IP
Second, rsync common options
-A contains-rtplgod
-r Sync Directory with the-R option similar to CP
-V synchronization displays some specific information to see the synchronization process
-L reserved Soft connection
-L plus option synchronizes source files when synchronizing soft connections
-P Small p maintains file ownership
-O Keep File owner
-G hold file of the genus Group
-D Keep Device file information
-T keep file Time properties
--delte Delete files that are not in src (source directory) in Dest (destination directory)
--exclude filter the specified file, such as--exclude "logs" will be the file name contains logs files or directory filtering, not synchronized
-P Large p shows the synchronization process, such as rate,-V more detailed
-U update Plus, if the file in dest is newer than SRC, it is out of sync
-Z Compression during transfer
Example: Synchronizing the/tmp/0.txt to the/root/ceshi.txt
Join behind/
Third, rsync synchronization via SSH
Rsync-av test1/192.168.1.106:/tmp/test2/
Reync-av-e "Ssh-p" test1/192.168.1.106:/tmp/test2/
Rsync is synchronized by service
To edit a configuration file/etc.rsyncd.conf
Start Service rsync--daemon
Format: Rsync-av test1/192.168.1.101::module/dir/
Two virtual machines synchronized with each other
First virtual machine synchronization root test1 to the second virtual machine/tmp/test2, you need to ensure that two virtual machines have rsync tools, and the directory must be created
Second virtual machine
Rsyncd.conf Sample Example
port=873
Log File=/var/log/rsync.log
PID File=/var/run/rsyncd.pid
Address=192.168.1.101
[Test]
Path=/root/rsync
Use Chroot=true
Max Connections=4
Read Only=no
List=true
Uid=root
Gid=root
Auth Users=test
Secrets file=/etc/rsyncd.passwd
Hosts allow=192.168.1.106 1.1.1.1 2.2.2.2 192.168.133.0/24
Linux centos7 rsync Tool Introduction, rsync common options, rsync synchronization via SSH