(1) rsync (remote synchronize) is a data synchronization tool that allows you to quickly sync files between multiple hosts via Lan/wan, or use rsync to synchronize different directories on your local hard drive.
(2) Rsync is a tool for replacing RCP, and rsync uses the so-called "Rsync algorithm" to synchronize files between local and remote two hosts, which transmits only the different parts of two files, rather than the entire transfer every time, so it is quite fast.
(3) Rsync supports most Unix-like systems, both Linux, Solaris, and BSD are well tested. In addition, it also has the corresponding version under the Windows platform, the more well-known have cwrsync and Sync2nas.
There are two ways to use rsync for remote synchronization: remote Shell mode (SSH is recommended, user authentication is handled by SSH) and C/s (i.e. the client connects to a remote rsync server, and user authentication is the responsibility of the Rsync server).
Whether the data is synchronized locally or remotely, the first run will copy all the files once, and then the runtime will copy only the changed files (for new files) or changes to the file (for the original file).
Rsync does not have a speed advantage when it is first copied, and it is not as fast as tar, so when the amount of data is large you might consider first copying with tar before using rsync for data synchronization.
Today you need to back up a directory file of more than 50 g to the backup machine, because the SCP does not support the continuation of the breakpoint, so naturally think of rsync to take this responsibility.
First of all, remember a few common parameters:
-a parameter, equivalent to-rlptgod,-r is the recursive-L is a linked file, which means to copy the link file;-p to maintain the original file permissions;-T to keep the file original user group;-O Keep the original owner of the file;-D is equivalent to the block device file;
-Z compression during transmission;
-V Transfer the progress of the information, try it yourself. can read the document;
-P equivalent to--partial keep those files that are not fully transmitted for any reason, that is, the breakpoint continues to pass!
Kind
Usage One:
Synchronize the/data/www directory on the host to the native/test directory: rsync-avz root @192.168.21.39:/data/www/test (Joben No test directory, it will be created automatically!) )
usage Two:
Synchronize the/data/www directory on the host to the native/test directory but exclude log catalogue: Rsync-avz[email protected]:/data/www--exclude=*/log/*/test
usage Three:
synchronization host on the/data/www directory to the native/test directory, the native/test directory already exists in the WWW directory, and there are already files, I want to keep the WWW file and host consistent, that is, the WWW directory can not have a different file with the host
rsync-avz [email protected]:/data/www--delete/test
This article is from the "broken cocoon into a Butterfly" blog, please be sure to keep this source http://qjslovemsn.blog.51cto.com/10615974/1704538
Shell command (ii) The art of Rsync