How to use rsync under Linux

Source: Internet
Author: User
Tags file copy rsync

How to use rsync under Linux

Spit Groove

  After summing up the SCP yesterday, I saw that there was finally a talk about Rsync, a cloud: Curiosity killed the cat. With the attitude of learning to find out the rsync, and then carried out some simple study. Here are a few common commands. The scp:12 of the previous article is a file for the SCP transfer of chestnuts.

Introduction

Rsync is a data mirroring Backup tool--remote Sync under Unix-like systems. A fast incremental backup tool remote sync that supports local replication or synchronizes with other SSH and rsync hosts.
For organizations and companies, data is the most important to them, and even for e-commerce, data is equally important. Rsync is a tool/software that backs up important data over the network. It is also a network protocol that synchronizes folders and files between systems on Unix-like and window systems over the network. Rsync can copy or display directories and copy files. Rsync listens to TCP 873 ports by default, copying files through remote shells such as rsh and SSH. Rsync must be installed on both remote and local systems.
The main benefits of rsync are:
  speed: All content is initially copied between local and remote. Next time, only the changed blocks or bytes will be transmitted.
  Secure: The transfer can encrypt data through the SSH protocol.
  Low Bandwidth:rsync can compress and decompress data blocks at both ends.
  Grammar:

1 #rsysnc [options] Source Path destination Path

  Here's a look at the specific usage tips.
                                                   First, enable compression, details, and recursion

1  [[email protected]/]# rsync-zvr/home/aloft//backuphomedir2    Building file list ... done  3.    bash_logout4    . Bash_profile5    . BASHRC6     sent 472 bytes received + bytes 1116.00 bytes/sec7     Total Size is 324 speedup is 0.58


- Z: This option is to enable compression, which can speed up the transfer, because it is compressed during transmission, but after the transfer is completed at the other end of the decompression, it will save time, generally can save a few times about the time, of course, for those already compressed files have no effect.
-V: This option enables you to view detailed information about the transfer so that you can see the feedback in a timely manner.
-R: This option is a recursive download that can be used to download the entire folder.
Ii. Preserve file and folder properties   

 1  [[email protected]/]# rsync-azvr/home/aloft//backuphomedir  2   building file List ... Done  4  . Bash_logout  5   Bash_profile  Span style= "color: #008080;" >6   7  8  sent 514 bytes received $ bytes 1212.00 bytes/sec  9  Total size was 324 speedup is 0.53 

-a: This option preserves the properties of a file or folder, such as the owning and owning groups, timestamps, soft links, and permissions.
Iii. synchronize local to remote host

  [email protected]/]# rsync-avz/home/aloft/[email protected ]:192.168.1.4:/share/rsysnctest/  password:< /span>  4   building file list ... done  ./ 6    7   Bash_profile   8    9  sent 514 bytes rece ived bytes 1212.00 bytes/sec  10  Total Size is 324 speedup is 0.53 

  This is relatively simple, as long as the remote host IP or host, as well as the user name, and know the password, then you can easily in the local and remote machine between the file or folder synchronization.
                                                     Four, remote synchronization to the local host

1[Email protected]/]# Rsync-avz [email protected]:192.168.1.4:/share/rsysnctest//home/aloft/2 Password:3 building file list ... done4./5 . Bash_logout6 . Bash_profile7 . BASHRC8Sent 514 bytes Received bytes 1212.00 bytes/sec9Total size is 324 speedup are 0.53-see more at:http://linoxide.com/how-tos/rsync-copy/#sthash. 2HSQUZPH.DPUF 

of course, there is synchronization to the remote nature will also have synchronized to the local scatter, this and the above three similar, just the opposite of the address ~
                                                    V. Find out the difference between documents

1[Email protected] backuphomedir]# rsync-avzi/backuphomedir/home/aloft/2 building file list ... done3cd+++++++ backuphomedir/4>f+++++++ backuphomedir/. Bash_logout5>f+++++++ backuphomedir/. Bash_profile6>f+++++++ backuphomedir/. BASHRC7>f+++++++ backuphomedir/ABC8>f+++++++ backuphomedir/XYZ9     TenSent 650 bytes received 136 bytes 1572.00 bytes/sec OneTotal size was 324 speedup is 0.41

  The above command can help you find the source address and destination address of the file or directory between the different.
-I: This option makes it easy to quickly locate modified files by listing different files or directories.
                                                    Vi. Backup

The rsync command can be used to back up Linux. You can use Rsync to schedule backups in Cron.

1  0 0 * * */usr/local/sbin/bkpscript &>/dev/null23  vi/usr/local/sbin/  Bkpscript45  rsync-avz-e ' ssh-p2093′/home/test/[email protected]:/oracle/data/

                                                    Seven, other related parameters:

1-V,--verbose verbose mode output2-Q,--quiet thin output mode3-C,--checksum turn on the check switch to force verification of file transfers4-A,--archive archive mode, which means to transfer files recursively and keep all file attributes equal to-Rlptgod5-R,--recursive recursive mode for subdirectories6-R,--relative using relative path information7-B,--backup creates a backup, that is, the old file is renamed to ~filename when the same file name exists for the purpose. Can be used--the suffix option to specify a different backup file prefix. 8--backup-dir the backup file (e.g. ~filename) is stored in the directory. 9-suffix=SUFFIX Defining backup file PrefixesTen-U,--Update only updates, that is, skips 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) One-L,--links Keep Soft links A-L,--copy-links treat soft links like regular files ---copy-unsafe-links only copy links that are not linked to the SRC path directory tree ---safe-Links Ignore links to the SRC Path directory tree the-H,--hard-links Keep Hard links --P,--perms Maintaining file permissions --O,--owner maintains file owner Information --G,--Group keep file belonging to groups information +-D,--devices Maintaining device file information --T,--times Keep file time information +-S,--sparse special processing of sparse files to save DST space A-N,--dry-run reality which files will be transmitted at-W,--whole-file copy files, no incremental detection --X,--one-file-System does not cross file system boundaries --B,--block-size=the size of the algorithm uses the size of the block, the default is 700 bytes --E,--rsh=COMMAND Specifies that data is synchronized using rsh and SSH ---rsync-path=Path Specifies the paths 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 in--existing only updates those files that already exist in DST without backing up those newly created files ---Delete deletes those files that are not in the DST SRC to--delete-excluded also deletes those files that are excluded by the option specified by the Receive side +--delete-after the transfer is finished, delete it again ---ignore-errors timely IO errors are also deleted the--max-delete=num deletes up to num files *--partial retains files that are not fully transmitted for any reason, to expedite subsequent transmissions $--force forces the removal of the directory, even if it is not emptyPanax Notoginseng--numeric-IDs does not match the user and group IDs of numbers to user names and group names ---timeout=time IP timeout in seconds the-I.,--ignore-times do not skip files that have the same time and length +--size-only view file size regardless of file time when deciding whether to back up files A--modify-window=NUM Determines whether the file is time-stamped with the time Stamp window, which defaults to 0 the-T--temp-dir=dir creates a temporary file in dir +--compare-dest=dir also compares the files in dir to determine if a backup is required --P is equivalent to--Partial $--Progress Show backup Process $-Z,--Compress compressing the backed-up files while they are being transmitted ---exclude=pattern Specifies to exclude file patterns that do not need to be transferred ---include=Pattern Specifies file patterns that need to be transferred without exclusion the--exclude-from=file excludes files in the specified schema in file ---include-from=file does not exclude files that specify pattern matchingWuyi--version print release information the--address is bound to a specific location ---config=File Specifies a different configuration file and does not use the default rsyncd.conf file Wu--port=Port Specifies the other rsync service ports ---blocking-io uses blocking IO for remote shells About-stats gives the transfer status of some files $--progress in the transmission of the real-time transmission process ---log-format=format Specifies log file formats ---password-file=file gets the password from file ---bwlimit=kbps Limit i/o bandwidth, Kbytes per second A-H,--help display Help information
View Code

  The above is about the use of rsync, not the point of welcome to say ~ After reading the harvest please leave footprints let me know ~
Reference article: http://linoxide.com/how-tos/rsync-copy/
Read MORE: Http://linux.die.net/man/1/rsync

   PS: This blog welcome forwarding, but please specify the blog address and author ~

Blog Address: http://www.cnblogs.com/voidy/

<. ))) ≦

 

How to use rsync under Linux

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.