源服务器有一个所有者,即 root。
----/home/sub1/test1
----/home/sub2/test1
Run Code Online (Sandbox Code Playgroud)
我的本地机器是目的地。
----/home/sub1/test1 owner by user1
----/home/sub2/test1 owner by user2
Run Code Online (Sandbox Code Playgroud)
如何将新的更新文件从源服务器同步到本地计算机并且不更改本地所有者?
编辑
我需要在一个命令中同步所有源,因为有许多文件夹和本地计算机也有许多所有者。也许有可能吗?
谢谢。
听起来您不希望它们在转移后发生变化。
尝试以下命令:
rsync -avr -o -g /source/directory user@:destinationHost/destination/directory
Run Code Online (Sandbox Code Playgroud)
如果不使用这些选项,用户和组将更改为接收端的调用用户。如果您想指定其他用户,则需要在脚本中添加 chown 命令。
-o, --owner
This option causes rsync to set the owner of the destination file to be
the same as the source file, but only if the receiving rsync is being run
as the super-user (see also the --super and --fake-super options). Without
this option, the owner of new and/or transferred files are set to the invoking
user on the receiving side...
-g, --group
This option causes rsync to set the group of the destination file to be the same as
the source file. If the receiving program is not running as the super-user (or if
--no-super was specified), only groups that the invoking user on the receiving side
is a member of will be preserved. Without this option, the group is set to the default
group of the invoking user on the receiving side...
SEE MAN rsync
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
47032 次 |
最近记录: |