如何将文件所有者从一个服务器复制到另一个服务器

时间:2022-11-15 19:57:08

I'm migrating several websites to a new server. I can scp the directories easily from one machine to the next, preserving permissions and whatnot, but I can't preserve the ownerships and groups. Obviously, the owner "fred" on one server will almost certainly have a different ID than "fred" on another server.

我正在将几个网站迁移到新服务器。我可以轻松地将目录从一台机器scp到下一台机器,保留权限等等,但我无法保留所有权和组。显然,一台服务器上的所有者“fred”几乎肯定会在另一台服务器上拥有与“fred”不同的ID。

So... Let's say that I have a file structure. Some of the files are owned by root, some by fred and some by wilma. On the new server, I'll create users "fred" and "wilma". Is there any way that I can somehow create some sort of archive on the old server that remembers who owns what so that on the new server, I can run it, chowning and chgrping all the files to fred or wilma?

所以......假设我有一个文件结构。一些文件由root拥有,一些由fred拥有,一些由wilma拥有。在新服务器上,我将创建用户“fred”和“wilma”。有没有什么方法可以在旧服务器上以某种方式创建某种存档,记住谁拥有什么,以便在新服务器上,我可以运行它,chowning chgrping所有文件到fred或wilma?

Don't know if I've been clear about that.

不知道我是否已经清楚这一点。

Or if there's a better way to do this, I'm all ears.

或者,如果有更好的方法来做到这一点,我会全力以赴。

1 个解决方案

#1


1  

It's not obvious at all that the user and group IDs will be different on the new server, especially if your servers have a common configuration set up by a configuration management tool.

根本不明显的是,新服务器上的用户和组ID会有所不同,特别是如果您的服务器具有配置管理工具设置的通用配置。

If you're setting up a new server, it's straightforward to replicate the users and groups from another server. See this blog post for an example of the steps involved.

如果您正在设置新服务器,则可以直接从其他服务器复制用户和组。有关所涉及步骤的示例,请参阅此博客文章。

#1


1  

It's not obvious at all that the user and group IDs will be different on the new server, especially if your servers have a common configuration set up by a configuration management tool.

根本不明显的是,新服务器上的用户和组ID会有所不同,特别是如果您的服务器具有配置管理工具设置的通用配置。

If you're setting up a new server, it's straightforward to replicate the users and groups from another server. See this blog post for an example of the steps involved.

如果您正在设置新服务器,则可以直接从其他服务器复制用户和组。有关所涉及步骤的示例,请参阅此博客文章。