📄 rsync.1
字号:
This has several effects: (1) in-use binaries cannot be updated (either theOS will prevent this from happening, or binaries that attempt to swap-intheir data will misbehave or crash), (2) the file's data will be in aninconsistent state during the transfer, (3) a file's data may be left in aninconsistent state after the transfer if the transfer is interrupted or ifan update fails, (4) a file that does not have write permissions can not beupdated, and (5) the efficiency of rsync's delta-transfer algorithm may bereduced if some data in the destination file is overwritten before it canbe copied to a position later in the file (one exception to this is if youcombine this option with \fB\-\-backup\fP, since rsync is smart enough to usethe backup file as the basis file for the transfer)..IP WARNING: you should not use this option to update files that are beingaccessed by others, so be careful when choosing to use this for a copy..IP This option is useful for transfer of large files with block-based changesor appended data, and also on systems that are disk bound, not networkbound..IP The option implies \fB\-\-partial\fP (since an interrupted transfer does not deletethe file), but conflicts with \fB\-\-partial\-dir\fP and \fB\-\-delay\-updates\fP.Prior to rsync 2.6.4 \fB\-\-inplace\fP was also incompatible with \fB\-\-compare\-dest\fPand \fB\-\-link\-dest\fP..IP .IP "\fB\-\-append\fP"This causes rsync to update a file by appending data ontothe end of the file, which presumes that the data that already exists onthe receiving side is identical with the start of the file on the sendingside. If a file needs to be transferred and its size on the receiver isthe same or longer than the size on the sender, the file is skipped. Thisdoes not interfere with the updating of a file's non-content attributes(e.g. permissions, ownership, etc.) when the file does not need to betransferred, nor does it affect the updating of any non-regular files.Implies \fB\-\-inplace\fP,but does not conflict with \fB\-\-sparse\fP (since it is always extending afile's length)..IP .IP "\fB\-\-append\-verify\fP"This works just like the \fB\-\-append\fP option, butthe existing data on the receiving side is included in the full-filechecksum verification step, which will cause a file to be resent if thefinal verification step fails (rsync uses a normal, non-appending\fB\-\-inplace\fP transfer for the resend)..IP Note: prior to rsync 3.0.0, the \fB\-\-append\fP option worked like\fB\-\-append\-verify\fP, so if you are interacting with an older rsync (or thetransfer is using a protocol prior to 30), specifying either append optionwill initiate an \fB\-\-append\-verify\fP transfer..IP .IP "\fB\-d, \-\-dirs\fP"Tell the sending side to include any directories thatare encountered. Unlike \fB\-\-recursive\fP, a directory's contents are not copiedunless the directory name specified is \(lq.\(rq or ends with a trailing slash(e.g. \(lq.\(rq, \(lqdir/.\(rq, \(lqdir/\(rq, etc.). Without this option or the\fB\-\-recursive\fP option, rsync will skip all directories it encounters (andoutput a message to that effect for each one). If you specify both\fB\-\-dirs\fP and \fB\-\-recursive\fP, \fB\-\-recursive\fP takes precedence..IP The \fB\-\-dirs\fP option is implied by the \fB\-\-files\-from\fP optionor the \fB\-\-list\-only\fP option (including an implied\fB\-\-list\-only\fP usage) if \fB\-\-recursive\fP wasn't specified (so thatdirectories are seen in the listing). Specify \fB\-\-no\-dirs\fP (or \fB\-\-no\-d\fP)if you want to turn this off..IP There is also a backward-compatibility helper option, \fB\-\-old\-dirs\fP (or\fB\-\-old\-d\fP) that tells rsync to use a hack of \(lq\-r \-\-exclude='/*/*'\(rq to getan older rsync to list a single directory without recursing..IP .IP "\fB\-l, \-\-links\fP"When symlinks are encountered, recreate thesymlink on the destination..IP .IP "\fB\-L, \-\-copy\-links\fP"When symlinks are encountered, the item thatthey point to (the referent) is copied, rather than the symlink. In olderversions of rsync, this option also had the side-effect of telling thereceiving side to follow symlinks, such as symlinks to directories. In amodern rsync such as this one, you'll need to specify \fB\-\-keep\-dirlinks\fP (\fB\-K\fP)to get this extra behavior. The only exception is when sending files toan rsync that is too old to understand \fB\-K\fP \(em in that case, the \fB\-L\fP optionwill still have the side-effect of \fB\-K\fP on that older receiving rsync..IP .IP "\fB\-\-copy\-unsafe\-links\fP"This tells rsync to copy the referent ofsymbolic links that point outside the copied tree. Absolute symlinksare also treated like ordinary files, and so are any symlinks in thesource path itself when \fB\-\-relative\fP is used. This option has noadditional effect if \fB\-\-copy\-links\fP was also specified..IP .IP "\fB\-\-safe\-links\fP"This tells rsync to ignore any symbolic linkswhich point outside the copied tree. All absolute symlinks arealso ignored. Using this option in conjunction with \fB\-\-relative\fP maygive unexpected results..IP .IP "\fB\-k, \-\-copy\-dirlinks\fP"This option causes the sending side to treata symlink to a directory as though it were a real directory. This isuseful if you don't want symlinks to non-directories to be affected, asthey would be using \fB\-\-copy\-links\fP..IP Without this option, if the sending side has replaced a directory with asymlink to a directory, the receiving side will delete anything that is inthe way of the new symlink, including a directory hierarchy (as long as\fB\-\-force\fP or \fB\-\-delete\fP is in effect)..IP See also \fB\-\-keep\-dirlinks\fP for an analogous option for the receivingside..IP .IP "\fB\-K, \-\-keep\-dirlinks\fP"This option causes the receiving side to treata symlink to a directory as though it were a real directory, but only if itmatches a real directory from the sender. Without this option, thereceiver's symlink would be deleted and replaced with a real directory..IP For example, suppose you transfer a directory \(lqfoo\(rq that contains a file\(lqfile\(rq, but \(lqfoo\(rq is a symlink to directory \(lqbar\(rq on the receiver. Without\fB\-\-keep\-dirlinks\fP, the receiver deletes symlink \(lqfoo\(rq, recreates it as adirectory, and receives the file into the new directory. With\fB\-\-keep\-dirlinks\fP, the receiver keeps the symlink and \(lqfile\(rq ends up in\(lqbar\(rq..IP One note of caution: if you use \fB\-\-keep\-dirlinks\fP, you must trust allthe symlinks in the copy! If it is possible for an untrusted user tocreate their own symlink to any directory, the user could then (on asubsequent copy) replace the symlink with a real directory and affect thecontent of whatever directory the symlink references. For backup copies,you are better off using something like a bind mount instead of a symlinkto modify your receiving hierarchy..IP See also \fB\-\-copy\-dirlinks\fP for an analogous option for the sending side..IP .IP "\fB\-H, \-\-hard\-links\fP"This tells rsync to look for hard-linked files inthe transfer and link together the corresponding files on the receivingside. Without this option, hard-linked files in the transfer are treatedas though they were separate files..IP When you are updating a non-empty destination, this option only ensuresthat files that are hard-linked together on the source are hard-linkedtogether on the destination. It does NOT currently endeavor to breakalready existing hard links on the destination that do not exist betweenthe source files. Note, however, that if one or more extra-linked fileshave content changes, they will become unlinked when updated (assuming youare not using the \fB\-\-inplace\fP option)..IP Note that rsync can only detect hard links between files that are insidethe transfer set. If rsync updates a file that has extra hard-linkconnections to files outside the transfer, that linkage will be broken. Ifyou are tempted to use the \fB\-\-inplace\fP option to avoid this breakage, bevery careful that you know how your files are being updated so that you arecertain that no unintended changes happen due to lingering hard links (andsee the \fB\-\-inplace\fP option for more caveats)..IP If incremental recursion is active (see \fB\-\-recursive\fP), rsync may transfera missing hard-linked file before it finds that another link for that contentsexists elsewhere in the hierarchy. This does not affect the accuracy ofthe transfer, just its efficiency. One way to avoid this is to disableincremental recursion using the \fB\-\-no\-inc\-recursive\fP option..IP .IP "\fB\-p, \-\-perms\fP"This option causes the receiving rsync to set thedestination permissions to be the same as the source permissions. (Seealso the \fB\-\-chmod\fP option for a way to modify what rsync considers tobe the source permissions.).IP When this option is \fIoff\fP, permissions are set as follows:.IP .RS .IP o Existing files (including updated files) retain their existingpermissions, though the \fB\-\-executability\fP option might change justthe execute permission for the file..IP o New files get their \(lqnormal\(rq permission bits set to the sourcefile's permissions masked with the receiving directory's defaultpermissions (either the receiving process's umask, or the permissionsspecified via the destination directory's default ACL), andtheir special permission bits disabled except in the case where a newdirectory inherits a setgid bit from its parent directory..RE.IP Thus, when \fB\-\-perms\fP and \fB\-\-executability\fP are both disabled,rsync's behavior is the same as that of other file-copy utilities,such as \fBcp\fP(1) and \fBtar\fP(1)..IP In summary: to give destination files (both old and new) the sourcepermissions, use \fB\-\-perms\fP. To give new files the destination-defaultpermissions (while leaving existing files unchanged), make sure that the\fB\-\-perms\fP option is off and use \fB\-\-chmod=ugo=rwX\fP (which ensures thatall non-masked bits get enabled). If you'd care to make this latterbehavior easier to type, you could define a popt alias for it, such asputting this line in the file ~/.popt (the following defines the \fB\-Z\fP option,and includes \-\-no\-g to use the default group of the destination dir):.IP .RS \f(CW rsync alias \-Z \-\-no\-p \-\-no\-g \-\-chmod=ugo=rwX\fP.RE.IP You could then use this new option in a command such as this one:.IP .RS \f(CW rsync \-avZ src/ dest/\fP.RE.IP (Caveat: make sure that \fB\-a\fP does not follow \fB\-Z\fP, or it will re-enablethe two \(lq\-\-no\-*\(rq options mentioned above.).IP The preservation of the destination's setgid bit on newly-createddirectories when \fB\-\-perms\fP is off was added in rsync 2.6.7. Older rsyncversions erroneously preserved the three special permission bits fornewly-created files when \fB\-\-perms\fP was off, while overriding thedestination's setgid bit setting on a newly-created directory. Default ACLobservance was added to the ACL patch for rsync 2.6.7, so older (ornon-ACL-enabled) rsyncs use the umask even if default ACLs are present.(Keep in mind that it is the version of the receiving rsync that affectsthese behaviors.).IP .IP "\fB\-E, \-\-executability\fP"This option causes rsync to preserve theexecutability (or non-executability) of regular files when \fB\-\-perms\fP isnot enabled. A regular file is considered to be executable if at least one\(oqx\(cq is turned on in its permissions. When an existing destination file'sexecutability differs from that of the corresponding source file, rsyncmodifies the destination file's permissions as follows:.IP .RS .IP o To make a file non-executable, rsync turns off all its \(oqx\(cqpermissions..IP o To make a file executable, rsync turns on each \(oqx\(cq permission thathas a corresponding \(oqr\(cq permission enabled..RE.IP If \fB\-\-perms\fP is enabled, this option is ignored..IP .IP "\fB\-A, \-\-acls\fP"This option causes rsync to update the destinationACLs to be the same as the source ACLs.The option also implies \fB\-\-perms\fP..IP The source and destination systems must have compatible ACL entries for thisoption to work properly. See the \fB\-\-fake\-super\fP option for a way to backupand restore ACLs that are not compatible..IP .IP "\fB\-X, \-\-xattrs\fP"This option causes rsync to update the remoteextended attributes to be the same as the local ones..IP For systems that support extended-attribute namespaces, a copy being done by asuper-user copies all namespaces except system.*. A normal user only copiesthe user.* namespace. To be able to backup and restore non-user namespaces asa normal user, see the \fB\-\-fake\-super\fP option..IP .IP "\fB\-\-chmod\fP"This option tells rsync to apply one or morecomma-separated \(lqchmod\(rq strings to the permission of the files in thetransfer. The resulting value is treated as though it was the permissionsthat the sending side supplied for the file, which means that this optioncan seem to have no effect on existing files if \fB\-\-perms\fP is not enabled..IP In addition to the normal parsing rules specified in the \fBchmod\fP(1)manpage, you can specify an item that should only apply to a directory byprefixing it with a \(oqD\(cq, or specify an item that should only apply to afile by prefixing it with a \(oqF\(cq. For example:.IP .RS \-\-chmod=Dg+s,ug+w,Fo-w,+X.RE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -