我刚刚发现我的备份缺少 ACL,并且在修复之前无法恢复。
幸运的是,我有幸检查权限在正在运行的系统上应该是什么样子,例如:
恢复:
# file: samba/sysvol
# owner: root
# group: 3000000
user::rwx
group::rwx
other::---
正在运行:
# file: samba/sysvol
# owner: root
# group: 3000000
user::rwx
user:root:rwx
group::rwx
group:3000000:rwx
group:3000001:r-x
group:3000002:rwx
group:3000003:r-x
mask::rwx
other::---
default:user::rwx
default:user:root:rwx
default:group::---
default:group:3000000:rwx
default:group:3000001:r-x
default:group:3000002:rwx
default:group:3000003:r-x
default:mask::rwx
default:other::---
没有简单的权限模式可以遵循,因此手动协调将花费很长时间并且容易出错。
问题:
是否可以“克隆”ACL 权限?
即递归读取所有文件和文件夹的 ACL(getfacl?)并写入(setacl?)到其他地方的相同文件和文件夹列表?
最佳答案
如果源和目标都在本地,或者您可以通过 SSH 或 rsync 协议(protocol)在它们之间进行复制,则可以使用 rsync -A
在目录之间复制 ACL。
这将在同一台机器上本地复制 ACL。
rsync -Ar dir1/ dir2/
如果两台服务器都有兼容的 ACL,您可以使用它通过网络复制 ACL,而无需实际再次复制文件。
rsync -Ar /dir1/ user@destination:/dir2/
或
rsync -Ar user@source:/dir1/ /dir2/
取决于您正在运行命令的服务器。
来自 rsync 手册页:
-A, --acls This option causes rsync to update the destination ACLs to be the same as the source ACLs. The option also implies --perms.
The source and destination systems must have compatible ACL entries for this option to work properly. See the --fake-super option for a way to backup and restore ACLs that are not compatible.
关于linux - 如何克隆ACL权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57162470/