我在 Linux 服务器上有一个远程文件系统的 sshfs 连接设置。我正在从本地服务器到 ftpfs 文件系统进行 rsync。由于此设置的性质,我无法chown对 sshfs 文件系统进行任何操作。
当我执行 rsync 时,它会在传输文件后尝试 chown 所有文件。这会导致 chown 错误,即使它可以很好地传输文件。
使用 rsync,有没有办法告诉它不要尝试 chown 文件?如果我 rsync 像 1000 个文件,我最终会得到 1000 个chown: permission denied (error 13)错误的日志。我知道得到这些错误不会有任何伤害,因为文件的所有权是由 sshfs 配置本身决定的,但最好不要得到它们。
acu*_*ich 117
您可能正在像这样运行 rsync:
rsync -a dir/ remote:/dir/
Run Code Online (Sandbox Code Playgroud)
根据文档的-a选项等效于:-rlptgoD
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
Run Code Online (Sandbox Code Playgroud)
您可能想要删除-o和-g选项:
-o, --owner preserve owner (super-user only)
-g, --group preserve group
Run Code Online (Sandbox Code Playgroud)
因此,您的 rsync 命令应该如下所示:
rsync -rlptD dir/ remote:/dir/
Run Code Online (Sandbox Code Playgroud)
或者正如@glglgl指出的那样:
rsync -a --no-o --no-g dir/ remote:/dir/
Run Code Online (Sandbox Code Playgroud)
其余使用的选项是:
-r, --recursive recurse into directories
-l, --links copy symlinks as symlinks
-p, --perms preserve permissions
-t, --times preserve modification times
-D same as --devices --specials
--devices preserve device files (super-user only)
--specials preserve special files
Run Code Online (Sandbox Code Playgroud)
不要使用该-a选项,因为它将包含-p保留权限的选项。对于这种情况,-r应该足够了。
有关更多信息,请参阅man rsync。