Introduction to Linux rsync parameters and commands

Source: Internet
Author: User
Tags file copy rsync

I. Introduction of RSYNC

rsync (remote Synchronize) is a long-distance data synchronization tool that can synchronize multiple hosts with Lan/wan quickly, and Rsync uses the "Rsync algorithm" for synchronization between the local host and the remote host, which is not the whole transfer of the algorithm every time. It transmits only the different parts of the data that are backed up between two computers, so it is very fast.

The advantages of rsync are as follows:

l support for copying special files such as linked files, devices, etc.

l can have the ability to exclude specified file or directory synchronization, which is equivalent to the Exclude function of Packaging command tar

l you can keep the source file or directory permissions, time, soft and hard links, owners, groups and all other properties do not change -p

l you can achieve incremental synchronization, which is to synchronize only the changed data, so the data transfer efficiency is very high,tar

l can use rcp,rsh,ssh and Other ways to coordinate the transfer of files (rsync itself does not encrypt data)

l Files and data can be transferred via socket(process mode)

l process mode transfer with anonymous or authenticated (no system users required) enables easy and secure data backup and mirroring

In addition, the transfer speed is not a hierarchical level compared to the SCP. We often use rsync and SCP to transfer a large number of MySQL data in the LAN, found that rsync is at least 20 times times faster than SCP, so if you need to transfer huge amounts of data between Linux/unix servers, rsync is a very good choice.

Second, the rsync command

The command format for rsync can be in the following six ways:


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::D EST

rsync [OPTION] ... rsync://[[email protected]]host[:P ort]/src [DEST]

1) Copy Local file: When the SRC and dest path information does not include a single ":" Delimiter, this mode of operation is initiated, 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. When the Dest path includes a single colon ":" delimiter, this mode of operation is initiated, 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. When the SRC path contains a single colon ":" delimiter, the device sends this mode of operation, such as: Rsync-avz foo:src/bar/backup

4) Copy files from the remote rsync server to the local machine. This mode is started when the SRC path information contains the "::" delimiter. such as: rsync-av [email Protected]::www/databack

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

6) The list of files for the remote machine is listed. This is similar to the rsync transfer, but only if the local machine information is omitted from the command. such as: Rsync-v rsync://192.168.1.100/www

Three, rsync parameters

The specific explanations for the rsync parameters are as follows:
-V,--verbose verbose mode output
-Q,--quiet thin output mode
-C,--checksum turn on the check switch to force verification of file transfers
-A,--archive archive mode, which means to transfer files recursively and keep all file attributes equal to-rlptgod
-R,--recursive subdirectories in recursive mode
-R,--relative using relative path information
-B,--backup creates a backup, that is, the old file is renamed to ~filename when the same file name exists for the purpose. You can use the--suffix option to specify a different backup file prefix.
--backup-dir store backup files (such as ~filename) in the directory.
-suffix=suffix Defining backup File prefixes
-U,--update only updates, which is to skip all the files that already exist in DST, and the file time is later than the file to be backed up. (Does not overwrite the updated file)
-L,--links reserved Soft link
-L,--copy-links to handle soft links like regular files
--copy-unsafe-links only copies links to links outside the SRC Path directory tree
--safe-links ignoring links to the SRC Path directory tree
-H,--hard-links reserved Hard link
-P,--perms maintain file permissions
-O,--owner keep file owner information
-G,--group keep file group information
-D,--devices keep device file information
-T,--times keep file time information
-S,--sparse special processing of sparse files to save DST space
-N,--dry-run reality which files will be transmitted
-W,--whole-file copy files without incremental detection
-X,--one-file-system do not cross file system boundaries
-B, the block size used by the--block-size=size test algorithm, is 700 bytes by default
-E,--rsh=command specifies data synchronization using RSH and SSH
--rsync-path=path Specify the path information for the rsync command on the remote server
-C,--cvs-exclude uses the same method as CVs to automatically ignore files to exclude files that you do not want to transfer
--existing only updates those files that already exist in DST without backing up those newly created files
--delete Delete those files that are not in the DST SRC
--delete-excluded also deletes those files that are excluded by the option specified by the Receive side
--delete-after transfer ends after removal
--ignore-errors Timely IO errors are also deleted
--max-delete=num deleting NUM files up to a maximum
--partial retains files that are not fully transmitted for any reason, to expedite subsequent transmissions
--force forcibly delete a directory, even if it is not empty
--numeric-ids does not match the user and group ID of a number to a user name and group name
--timeout=time IP time-out, in seconds
-I,--ignore-times do not skip files that have the same time and length
--size-only when deciding whether to back up a file, just look at the file size regardless of file time
--modify-window=num determines whether the file is time-stamped with the time Stamp window, which defaults to 0
-t--temp-dir=dir creating temporary files in Dir
--compare-dest=dir also compares the files in DIR to determine if a backup is required
-p equivalent to--partial
--progress Show Backup process
-Z,--compress compress the backed-up files during transmission
--exclude=pattern specify to exclude file modes that do not need to be transferred
--include=pattern specifies file modes that need to be transferred without exclusion
--exclude-from=file exclude files in the specified schema in file
--include-from=file does not exclude files that specify pattern matching
--version Print version Information
--address binding to a specific address
--config=file specify a different configuration file, do not use the default rsyncd.conf file
--port=port Specify a different rsync service port
--blocking-io using blocking IO for remote shells
-stats gives the transfer status of some files
--progress in the transmission of the real-time transmission process
--log-format=format specifying the log file format
--password-file=file get the password from file
--bwlimit=kbps limit I/O bandwidth, Kbytes per second
-H,--help display Help information

Generally, we will only use the AVZ option.

This article is from "A Little Rookie" blog, please be sure to keep this source http://aresxin.blog.51cto.com/4734097/1610720

Introduction to Linux rsync parameters and commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.