📄 rsync.yo
字号:
bf(--recursive) option, rsync will skip all directories it encounters (andoutput a message to that effect for each one). If you specify bothbf(--dirs) and bf(--recursive), bf(--recursive) takes precedence.The bf(--dirs) option is implied by the bf(--files-from) optionor the bf(--list-only) option (including an impliedbf(--list-only) usage) if bf(--recursive) wasn't specified (so thatdirectories are seen in the listing). Specify bf(--no-dirs) (or bf(--no-d))if you want to turn this off.There is also a backward-compatibility helper option, bf(--old-dirs) (orbf(--old-d)) that tells rsync to use a hack of "-r --exclude='/*/*'" to getan older rsync to list a single directory without recursing.dit(bf(-l, --links)) When symlinks are encountered, recreate thesymlink on the destination.dit(bf(-L, --copy-links)) 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 bf(--keep-dirlinks) (bf(-K))to get this extra behavior. The only exception is when sending files toan rsync that is too old to understand bf(-K) -- in that case, the bf(-L) optionwill still have the side-effect of bf(-K) on that older receiving rsync.dit(bf(--copy-unsafe-links)) 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 bf(--relative) is used. This option has noadditional effect if bf(--copy-links) was also specified.dit(bf(--safe-links)) This tells rsync to ignore any symbolic linkswhich point outside the copied tree. All absolute symlinks arealso ignored. Using this option in conjunction with bf(--relative) maygive unexpected results.dit(bf(-k, --copy-dirlinks)) 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 bf(--copy-links).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 asbf(--force) or bf(--delete) is in effect).See also bf(--keep-dirlinks) for an analogous option for the receivingside.dit(bf(-K, --keep-dirlinks)) 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.For example, suppose you transfer a directory "foo" that contains a file"file", but "foo" is a symlink to directory "bar" on the receiver. Withoutbf(--keep-dirlinks), the receiver deletes symlink "foo", recreates it as adirectory, and receives the file into the new directory. Withbf(--keep-dirlinks), the receiver keeps the symlink and "file" ends up in"bar".One note of caution: if you use bf(--keep-dirlinks), 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.See also bf(--copy-dirlinks) for an analogous option for the sending side.dit(bf(-H, --hard-links)) 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.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 bf(--inplace) option).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 bf(--inplace) 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 bf(--inplace) option for more caveats).If incremental recursion is active (see bf(--recursive)), 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 bf(--no-inc-recursive) option.dit(bf(-p, --perms)) This option causes the receiving rsync to set thedestination permissions to be the same as the source permissions. (Seealso the bf(--chmod) option for a way to modify what rsync considers tobe the source permissions.)When this option is em(off), permissions are set as follows:quote(itemization( it() Existing files (including updated files) retain their existing permissions, though the bf(--executability) option might change just the execute permission for the file. it() New files get their "normal" permission bits set to the source file's permissions masked with the receiving directory's default permissions (either the receiving process's umask, or the permissions specified via the destination directory's default ACL), and their special permission bits disabled except in the case where a new directory inherits a setgid bit from its parent directory.))Thus, when bf(--perms) and bf(--executability) are both disabled,rsync's behavior is the same as that of other file-copy utilities,such as bf(cp)(1) and bf(tar)(1).In summary: to give destination files (both old and new) the sourcepermissions, use bf(--perms). To give new files the destination-defaultpermissions (while leaving existing files unchanged), make sure that thebf(--perms) option is off and use bf(--chmod=ugo=rwX) (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 bf(-Z) option,and includes --no-g to use the default group of the destination dir):quote(tt( rsync alias -Z --no-p --no-g --chmod=ugo=rwX))You could then use this new option in a command such as this one:quote(tt( rsync -avZ src/ dest/))(Caveat: make sure that bf(-a) does not follow bf(-Z), or it will re-enablethe two "--no-*" options mentioned above.)The preservation of the destination's setgid bit on newly-createddirectories when bf(--perms) is off was added in rsync 2.6.7. Older rsyncversions erroneously preserved the three special permission bits fornewly-created files when bf(--perms) 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.)dit(bf(-E, --executability)) This option causes rsync to preserve theexecutability (or non-executability) of regular files when bf(--perms) isnot enabled. A regular file is considered to be executable if at least one'x' 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:quote(itemization( it() To make a file non-executable, rsync turns off all its 'x' permissions. it() To make a file executable, rsync turns on each 'x' permission that has a corresponding 'r' permission enabled.))If bf(--perms) is enabled, this option is ignored.dit(bf(-A, --acls)) This option causes rsync to update the destinationACLs to be the same as the source ACLs.The option also implies bf(--perms).The source and destination systems must have compatible ACL entries for thisoption to work properly. See the bf(--fake-super) option for a way to backupand restore ACLs that are not compatible.dit(bf(-X, --xattrs)) This option causes rsync to update the remoteextended attributes to be the same as the local ones.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 bf(--fake-super) option.dit(bf(--chmod)) This option tells rsync to apply one or morecomma-separated "chmod" 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 bf(--perms) is not enabled.In addition to the normal parsing rules specified in the bf(chmod)(1)manpage, you can specify an item that should only apply to a directory byprefixing it with a 'D', or specify an item that should only apply to afile by prefixing it with a 'F'. For example:quote(--chmod=Dg+s,ug+w,Fo-w,+X)It is also legal to specify multiple bf(--chmod) options, as eachadditional option is just appended to the list of changes to make.See the bf(--perms) and bf(--executability) options for how the resultingpermission value can be applied to the files in the transfer.dit(bf(-o, --owner)) This option causes rsync to set the owner of thedestination file to be the same as the source file, but only if thereceiving rsync is being run as the super-user (see also the bf(--super)and bf(--fake-super) options).Without this option, the owner of new and/or transferred files are set tothe invoking user on the receiving side.The preservation of ownership will associate matching names by default, butmay fall back to using the ID number in some circumstances (see also thebf(--numeric-ids) option for a full discussion).dit(bf(-g, --group)) This option causes rsync to set the group of thedestination file to be the same as the source file. If the receivingprogram is not running as the super-user (or if bf(--no-super) wasspecified), only groups that the invoking user on the receiving sideis a member of will be preserved.Without this option, the group is set to the default group of the invokinguser on the receiving side.The preservation of group information will associate matching names bydefault, but may fall back to using the ID number in some circumstances(see also the bf(--numeric-ids) option for a full discussion).dit(bf(--devices)) This option causes rsync to transfer character andblock device files to the remote system to recreate these devices.This option has no effect if the receiving rsync is not run as thesuper-user (see also the bf(--super) and bf(--fake-super) options).dit(bf(--specials)) This option causes rsync to transfer special filessuch as named sockets and fifos.dit(bf(-D)) The bf(-D) option is equivalent to bf(--devices) bf(--specials).dit(bf(-t, --times)) This tells rsync to transfer modification times alongwith the files and update them on the remote system. Note that if thisoption is not used, the optimization that excludes files that have not beenmodified cannot be effective; in other words, a missing bf(-t) or bf(-a) willcause the next transfer to behave as if it used bf(-I), causing all files to beupdated (though rsync's delta-transfer algorithm will make the update fairly efficientif the files haven't actually changed, you're much better off using bf(-t)).dit(bf(-O, --omit-dir-times)) This tells rsync to omit directories whenit is preserving modification times (see bf(--times)). If NFS is sharingthe directories on the receiving side, it is a good idea to use bf(-O).This option is inferred if you use bf(--backup) without bf(--backup-dir).dit(bf(--super)) This tells the receiving side to attempt super-useractivities even if the receiving rsync wasn't run by the super-user. Theseactivities include: preserving users via the bf(--owner) option, preservingall groups (not just the current user's groups) via the bf(--groups)option, and copying devices via the bf(--devices) option. This is usefulfor systems that allow such activities without being the super-user, and
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -