Rsync command of Linux command

Time:2020-1-16

Rsync command

Rsync command is a remote data synchronization tool, which can quickly synchronize files between multiple hosts through LAN / WAN. Rsync uses the so-called “Rsync algorithm” to synchronize the files between the local and remote hosts. This algorithm only transmits different parts of the two files, rather than the whole file every time, so the speed is quite fast. Rsync is a very powerful tool, and its commands also have many feature options. We will analyze and explain the options one by one.

grammar


rsync [OPTION]... SRC DEST
rsync [OPTION]... SRC [[email protected]]host:DEST
rsync [OPTION]... [[email protected]]HOST:SRC DEST
rsync [OPTION]... [[email protected]]HOST::SRC DEST
rsync [OPTION]... SRC [[email protected]]HOST::DEST
rsync [OPTION]... rsync://[[email protected]]HOST[:PORT]/SRC [DEST]

Corresponding to the above six command formats, Rsync has six different working modes:

Copy local files. This mode of operation is initiated when neither SRC nor des path information contains a single colon ‘:’ separator. Such as:rsync -a /data /backup

Use a remote shell program (such as RSH, SSH) to copy the contents of the local machine to the remote machine. This mode is started when the DST path address contains a single colon ‘:’ separator. Such as:rsync -avz *.c foo:src

Use a remote shell program (such as RSH, SSH) to copy the contents of the remote machine to the local machine. This mode is started when the SRC address path contains a single colon ‘:’ separator. Such as:rsync -avz foo:src/bar /data

Copy files from the remote Rsync server to the local machine. This mode is started when the SRC path information contains the ‘::’ separator. For example: Rsync – AV root @ 192.168.78.192:: WWW / databack

Copy files from the local machine to the remote Rsync server. This mode is started when DST path information contains the ‘::’ separator. For example: Rsync – AV / databack root @ 192.168.78.192:: www

Column the list of files for the remote machine. This is similar to Rsync transmission, but you can omit the local information in the command. For example: Rsync – V rsync://192.168.78.192/www

Parameter options

-v. -- verbose verbose mode output. 
-q. -- quiet reduced output mode. 
-c. -- check sum turn on the check switch to force the file transfer to be checked. 
-a. -- archive archive mode, which means to transfer files recursively and keep all file attributes equal to - rlptgod. 
-r. -- recursive handles subdirectories in recursive mode. 
-R. -- relative uses relative path information. 
-b. -- backup creates a backup, that is, when the same file name already exists for the purpose, rename the old file to ~ filename. You can use the -- suffix option to specify a different backup file prefix.
--Backup dir stores backup files (such as ~ filename) in the directory. -Suffix = suffix defines the backup file prefix. 
-u. -- update only updates, that is, skip all files that already exist in DST, and the file time is later than the file to be backed up, and do not overwrite the updated file. 
-l. -- links keep soft links. 
-50. -- copy links want to treat soft links like regular files. 
--Copy unsafe links only copies links that point outside the SRC tree. 
--Safe links ignores links that point outside the SRC tree. 
-H. -- hard links keep hard links. 
-p. -- perms maintains file permissions. 
-o. -- owner keeps the file owner information. 
-g. -- group keeps the file group information. 
-D. -- devices keep device file information. 
-t. -- times keeps the file time information. 
-S. -- sparse performs special processing on sparse files to save DST space. 
-n. -- dry run specifies which files will be transferred. 
-w. -- whole file copies files without incremental detection. 
-x. -- one file system do not cross file system boundaries. 
-B. -- block size = the block size used by the size verification algorithm, which is 700 bytes by default. 
-e. -- RSH = command specifies that RSH and SSH are used for data synchronization.
--Rsync path = path specifies the path information of the Rsync command on the remote server. 
-C. -- CVS exclude automatically ignores files in the same way as CVs to exclude files that you do not want to transfer. 
--Existing only updates files that already exist in the DST, rather than backing up newly created files. 
--Delete delete files that SRC does not have in DST. 
--Delete excluded also deletes the files excluded by this option.
--Delete after the transmission ends. 
--Ignore errors are deleted in case of IO errors. 
--Max delete = num delete up to num files. 
--Partial preserves files that are not fully transferred for some reason to speed up subsequent retransmissions. 
--Force forces the deletion of directories, even if they are not empty. 
--Numeric IDS does not match numeric user and group IDs to user and group names. 
--Timeout = time IP timeout in seconds. 
-1. -- ignore times does not skip files of the same length and time. 
--Size only when deciding whether to back up a file, only look at the file size regardless of the file time. 
--Modify window = the timestamp window used when num determines whether files have the same time. The default is 0. 
-T -- temp dir = dir creates a temporary file in dir. 
--Compare dest = dir also compares files in the dir to determine if a backup is required. 
-P is equivalent to -- partial. 
--Progress displays the backup process. 
-z. -- compress compresses the backed up files during transmission.
 --Exclude = pattern specifies to exclude file patterns that do not need to be transferred.
 --Include = pattern specifies the file mode to be transferred without exclusion.
 --Exclude from = file excludes files with the specified mode in file.
 --Include from = file does not exclude files that match the pattern specified by file. 
--Version prints version information. 
--Address is bound to a specific address. 
--Config = file specifies another configuration file, not the default rsyncd.conf file. 
--Port = port specifies another Rsync service port. 
--Blocking IO uses blocking io for remote shells. 
-Stats gives the transfer status of some files. 
--Progress implements the transfer process when transferring.
--Log format = format specifies the log file format. 
--Password file = file gets the password from file. 
--Bwlimit = Kbps limits I / O bandwidth, Kbytes per second. 
-h. -- help displays help information.

summary

The above is a detailed explanation of Rsync command of Linux command introduced by Xiaobian to you, hoping to help you. If you have any questions, please leave a message to me, and Xiaobian will reply you in time. Thank you very much for your support of the developepaer website!