[Linux rsync remote synchronization]

rsync is a utility for efficiently transferring and synchronizing files across computer systems, by checking the timestamp and size of files.It is commonly found on Unix-like systems and functions as both a file synchronization and file transfer program. The rsync algorithm is a type of delta encoding, and is used for minimizing network usage. Zlib may be used for additional compression,and SSH or stunnel can be used for data security.

 

Rsync is typically used for synchronizing files and directories between two different systems. For example, if the command rsync local-file user@remote-host:remote-file is run, rsync will use SSH to connect as user to remote-host.Once connected, it will invoke the remote host's rsync and then the two programs will determine what parts of the file need to be transferred over the connection.

 

Rsync can also operate in a daemon mode, serving files in the native rsync protocol (using the "rsync://" syntax).

 

 

rsync is a data mirror backup tool under Unix-like systems - remote sync. A fast incremental backup tool Remote Sync, remote synchronization supports local replication, or synchronization with other SSH, rsync hosts.

rsync, remote synchronize, as the name implies, knows that it is a software that realizes the remote synchronization function. While synchronizing files, it can maintain additional information such as the permissions, time, soft and hard links of the original files. rsync is a fast method of file synchronization between a client and a remote file server using the "rsync algorithm", and it can transfer files through ssh, so its confidentiality is also very good, and it is also free software.

 

 

 

The rsync features are as follows:

Entire directory trees and file systems can be mirrored.

It is easy to maintain the original file permissions, time, hard and soft links, etc.

No special permissions are required to install.

Fast: rsync copies the entire contents on the first sync, but transfers only the modified files the next time. rsync can perform compression and decompression operations in the process of transferring data, so it can use less bandwidth.

Security: You can use scp, ssh, etc. to transfer files, of course, you can also use a direct socket connection.

Anonymous transmission is supported to facilitate website mirroring.

 

 

rsync has six different working modes:

1) Copy the local file . This mode of operation is enabled when neither SRC nor DES path information contains a single colon ":" separator. Such as: rsync -a /data /backup

2) Use a remote shell program (such as rsh, ssh) to copy the contents of the local machine to the remote machine. This mode is activated when the DST path address contains a single colon ":" separator. Such as: rsync -avz *.c foo:src

3) Use a remote shell program (such as rsh, ssh) to copy the contents of the remote machine to the local machine. This mode is enabled when the SRC address path contains a single colon ":" separator. Such as: rsync -avz foo:src/bar /data

4) Copy files from the remote rsync server to the local machine . This mode is enabled when the SRC path information contains the "::" separator. For example: rsync -av [email protected]::www /databack

5) Copy files from the local machine to the remote rsync server . This mode is activated when the DST path information contains the "::" separator. For example: rsync -av /databack [email protected]::www

6) List the file list of the remote machine . This is similar to an rsync transfer, except that the local machine information is omitted from the command. Such as: rsync -v rsync://192.168.78.192/www

 

 

Before using the rsync command to synchronize system files, you must log in to the remote host for authentication. There are two protocols used in the authentication process: ssh protocol and rsync protocol

1. ssh authentication protocol

The rsync server side does not need to start the rsync daemon process, as long as you obtain the username and password of the remote host, you can directly rsync the files

Because the rsync server does not need to start the daemon process, it does not need to configure the file /etc/rsyncd.conf

The principle of the ssh authentication protocol is the same as that of scp. If you do not need to receive a password during the synchronization process, use ssh-keygen -t rsa to open the channel

This method omits -e ssh by default, which is equivalent to the following:

rsync -avz /SRC -e ssh [email protected]:/DEST #-a File host changes, timestamp unchanged -z: Compressed data transmission

When we need to modify the port, we can:

rsync -avz /SRC -e "ssh -p36000" [email protected]:/DEST #Modified the port of the ssh protocol, the default is 22

2. rsync authentication protocol

rsync authentication protocol, you need to start the daemon process on the rsync server and set the corresponding configuration file: /etc/rsyncd.conf 

rysnc authentication protocol

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326400756&siteId=291194637