大网数据广告活动
服务器运维问答

How to tell rsync do not check permissions

· 52CE 我爱测

I have two directories with same PHP application in every of them. I want to execute rsync -rvz from one, source directory to another, destination, so rsync will copy changed files only. Problem is that files in the source direct…

问题原文

原帖链接 · Evgenii Iablokov · CC BY-SA 3.0

I have two directories with same PHP application in every of them. I want to execute rsync -rvz from one, source directory to another, destination, so rsync will copy changed files only. Problem is that files in the source directory has 755 permissions, by mistake. Permissions in destination are fine.

How can I tell to rsync ignore permission checkings and check by size only? Thanks.

已采纳解答

原帖链接 · Drew Khoury · CC BY-SA 3.0

As long as you don't supply the -p flag permissions shouldn't be changed. If you're still not getting the permissions you expect make sure perms is off and use --chmod=ugo=rwX

For reference: http://linux.die.net/man/1/rsync

 -r, --recursive             recurse into directories
 -v, --verbose               increase verbosity
 -z, --compress              compress file data during the transfer
 -n, --dry-run               perform a trial run with no changes made

 -p, --perms                 preserve permissions
 -E, --executability         preserve executability
     --chmod=CHMOD           affect file and/or directory permissions

-p, --perms This option causes the receiving rsync to set the destination permissions to be the same as the source permissions. (See also the --chmod option for a way to modify what rsync considers to be the source permissions.)

The man page goes on to say:

In summary: to give destination files (both old and new) the source permissions, use --perms. To give new files the destination-default permissions (while leaving existing files unchanged), make sure that the --perms option is off and use --chmod=ugo=rwX (which ensures that all non-masked bits get enabled).

Side-note: If possible it might make more sense for your developer to be pushing their changes back into the repo, and have all servers use a code repo, rather then use rsync to ship files form one server to the other.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-04-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。