背景
通常,rsync
如果出现以下情况,您将看到警告:
rsync
另一端的服务器不具有执行与以下内容关联的操作的权限:
- 或远程端的文件系统不支持与发送方相同类型的元数据(权限,所有权等)
当尝试将文件/目录复制到接收方时,这些问题将通过rsync
尝试与rsync
服务器进行通信的客户端来表现出来,如下所示:
所有者
rsync:chown“ / mnt / music / The Fleetwood Mac / Trilogy-2006 / Trilogy-2006-CD 3 / 311_fleetwood_mac _-_ eyes_of_the_world.mp3”失败:不允许的操作(1)
组
rsync:chgrp“ / mnt / music / The Fleetwood Mac Discography by Sketch / Trilogy-2006 / Trilogy-2006-CD 3 / 311_fleetwood_mac _-_ eyes_of_the_world.mp3”失败:不允许的操作(1)
权限
rsync:无法设置“ / mnt / music / The Fleetwood Mac Discography by Sketch / Trilogy-2006 / Trilogy-2006-CD 3”的权限:不允许进行操作(1)
在接收方无法执行这些操作的情况下,您可以指示rsync
仅跳过尝试执行这些操作,从而意识到目的地与文件周围发件人的元数据并不完全相同。这仍将创建文件和目录的二进制部分的相同副本。
要告诉您rsync
不要担心元数据,您可以使用--no-OPTION
禁用任何这些隐含选项。
rsync手册页
--no-OPTION
You may turn off one or more implied options by prefixing the option name
with “no-”. Not all options may be prefixed with a “no-”: only options that
are implied by other options (e.g. --no-D, --no-perms) or have
different defaults in various circumstances (e.g. --no-whole-file,
--no-blocking-io, --no-dirs). You may specify either the short or the long
option name after the “no-” prefix (e.g. --no-R is the same as --no-relative).
For example: if you want to use -a (--archive) but don’t want -o (--owner),
instead of converting -a into -rlptgD, you could specify -a --no-o (or -a
--no-owner).
The order of the options is important: if you specify --no-r -a, the -r
option would end up being turned on, the opposite of -a --no-r.
Note also that the side-effects of the --files-from option are NOT positional,
as it affects the default state of several options and slightly changes the
meaning of -a (see the --files-from option for more details).
因此,在我们的案例中,我们想使用类似这样的功能来禁用这些功能:
$ rsync -avz --no-o --no-g --no-perms <src> <dst>
例
$ rsync -avz --delete --no-o --no-g --no-perms The\ Fleetwood\ Mac/ /mnt/music/The\ Fleetwood\ Mac/.
sending incremental file list
Trilogy - 2006/
Trilogy - 2006/Trilogy - 2006 - CD 3/
Trilogy - 2006/Trilogy - 2006 - CD 3/301_fleetwood_mac_-_love_in_store.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/302_fleetwood_mac_-_cant_go_back.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/303_fleetwood_mac_-_thats_alright.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/304_fleetwood_mac_-_book_of_love.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/305_fleetwood_mac_-_gypsy.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/306_fleetwood_mac_-_only_over_you.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/307_fleetwood_mac_-_empire_state.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/308_fleetwood_mac_-_straight_back.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/309_fleetwood_mac_-_hold_me.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/310_fleetwood_mac_-_oh_diane.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/311_fleetwood_mac_-_eyes_of_the_world.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/312_fleetwood_mac_-_wish_you_were_here.mp3
sent 61993245 bytes received 289 bytes 17712438.29 bytes/sec
total size is 2596551439 speedup is 41.88
另类
发生这种情况的另一个原因是由于使用了-a
开关。-a
包括一系列开关:
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-a
您可以使用单个开关来代替使用,而不必使用--no-OPTION
。
这些是随附的单个选项 -a
-r, --recursive recurse into directories
-l, --links copy symlinks as symlinks
-p, --perms preserve permissions
-t, --times preserve modification times
-o, --owner preserve owner (super-user only)
-g, --group preserve group
-D same as --devices --specials
--devices preserve device files (super-user only)
--specials preserve special files
这样,上面的示例将变成这样:
$ rsync -rltDvz --delete The\ Fleetwood\ Mac/ /mnt/music/The\ Fleetwood\ Mac/.
sending incremental file list
Trilogy - 2006/
Trilogy - 2006/Trilogy - 2006 - CD 3/
Trilogy - 2006/Trilogy - 2006 - CD 3/301_fleetwood_mac_-_love_in_store.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/302_fleetwood_mac_-_cant_go_back.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/303_fleetwood_mac_-_thats_alright.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/304_fleetwood_mac_-_book_of_love.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/305_fleetwood_mac_-_gypsy.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/306_fleetwood_mac_-_only_over_you.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/307_fleetwood_mac_-_empire_state.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/308_fleetwood_mac_-_straight_back.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/309_fleetwood_mac_-_hold_me.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/310_fleetwood_mac_-_oh_diane.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/311_fleetwood_mac_-_eyes_of_the_world.mp3
Trilogy - 2006/Trilogy - 2006 - CD 3/312_fleetwood_mac_-_wish_you_were_here.mp3
sent 61993245 bytes received 289 bytes 17712438.29 bytes/sec
total size is 2596551439 speedup is 41.88