问题原文
原帖链接 · Arnoldo Bazaldua · CC BY-SA 3.0
I´m trying to set owner and group via rsync and it doesn't seem to be working.
This is the command:
sudo rsync -rlptDvz --owner=cmsseren --group=cmsseren /home/serena/public_html/ -e ssh root@ip:/home/cmsseren/public_html2/
The files sync correctly but doesn´t seem to change the owner and group.
社区高分解答
原帖链接 · David Thompson · CC BY-SA 4.0
Version 3.1.0 of rsync introduced the --usermap and --groupmap mentioned by Thomas, but also the convenience option --chown, which works well for your scenario.
--chown=USER:GROUP
This option forces all files to be owned by USER with group GROUP.
This is a simpler interface than using --usermap and --groupmap directly,
but it is implemented using those options internally, so you cannot mix them.
If either the USER or GROUP is empty, no mapping for the omitted user/group will
occur. If GROUP is empty, the trailing colon may be omitted, but if USER is
empty, a leading colon must be supplied.
If you specify "--chown=foo:bar, this is exactly the same as specifying
"--usermap=*:foo --groupmap=*:bar", only easier.
Also, the -o and -g options are required. Excluding them will fail to update their respective attribute, but produce no error.
rsync -og --chown=cmsseren:cmsseren [src] [dest]
This is mentioned indirectly in the manpage, which
states that the --chown option "is implemented using --usermap and --groupmap internally", and:
For the
--usermapoption to have any effect, the-o(--owner) option must be used (or implied), and the receiver will need to be running as a super-user (see also the--fake-superoption).For the
--groupmapoption to have any effect, the-g(--groups) option must be used (or implied), and the receiver will need to have permissions to set that group.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
