Preserve macOS extended attributes in private NAS-side archive
这个提交包含在:
1 父节点
604fce4fec
当前提交
1f598007d1
2 个文件已更改
+61
-3
没有与搜索条件相匹配的文件
+5
-3
@@ -17,6 +17,8 @@
|
||||
- 复制后校验先前已存在文件的完整校验和,并作目录差异核验;不同版本保留不覆盖,需按检查结果处理。新文件使用 rsync 传输校验,不声称进行了独立的全盘逐字节读回。
|
||||
- 结束时程序卸载 APFS 并恢复其内核只读标志,检查源分区写计数。错误/不一致记录在同目录日志。仅普通素材与工程的本地 NAS 备份,不把素材、文件名清单或用户数据提交到 Git。
|
||||
- 用户要求报告实际拷贝速度与剩余时间;持续在当前任务观察至完成。未实现飞牛 FPK 或系统文件管理集成。
|
||||
- 已把原始 macOS 扩展属性另存至目标内隐藏目录 `.dayu-apfs-metadata-20261111-223613`:7374 条路径记录、1690603 字节;未发现 ResourceFork 属性。此存档可能包含私人元数据,禁止上传 Git。普通文件保留其数据内容;原始属性作为存档保存,不盲目应用机器相关安全属性。
|
||||
- 22:38 左右已传约 39.2 GB,实测平均约 256 MB/s、即时约 250 MB/s;动态进度以 NAS 的 copy.log 为准,不以本条历史快照判定任务完成。
|
||||
|
||||
## 已确认
|
||||
|
||||
@@ -53,6 +55,6 @@
|
||||
|
||||
## 待完成
|
||||
|
||||
1. 等待用户确认普通测试文件情况;建议 100–500 MB 视频,若可提供 macOS 的 SHA-256 则做独立比对。拔卡前从飞牛系统推出整张卡。
|
||||
2. 继续使用 PARTUUID 和 USB 身份核对,不假设重新插入后仍为 sde2;重新格式化后 PARTUUID 也会变化。
|
||||
3. 应用界面、FPK、自动识别、系统文件管理集成及真实 SSD 性能尚未实现,本阶段不是正式应用交付。
|
||||
1. 跟进本轮约 501 GB 复制任务至结束,核验已有 64 个文件及完整目录差异;如发现不同版本,先保留旧内容再处理,不盲目覆盖。
|
||||
2. 核实任务最终状态、APFS 源盘零写入、正常卸载与只读标志恢复;检查目标用户可访问性,保存脱敏结果与源码检查点。
|
||||
3. 应用界面、FPK、自动识别、系统文件管理集成尚未实现,本阶段不是正式应用交付。后续按真实盘数据表现决定驱动与封装方案。
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Archive macOS extended attributes beside a NAS backup, without applying them.
|
||||
|
||||
Attribute values may contain private user information. Output stays on the NAS.
|
||||
"""
|
||||
import base64
|
||||
import collections
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
config = json.loads(Path(sys.argv[1]).read_text())
|
||||
source = Path(config['mount']) / config['source_root']
|
||||
destination = Path(sys.argv[2])
|
||||
destination.mkdir(mode=0o700)
|
||||
os.chown(destination, 1000, 1001)
|
||||
count = collections.Counter()
|
||||
entries = 0
|
||||
output = destination / 'extended-attributes.jsonl'
|
||||
fd = os.open(output, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600)
|
||||
with os.fdopen(fd, 'w') as stream:
|
||||
for name in config['directories']:
|
||||
folder = source / name
|
||||
paths = [folder]
|
||||
for base, dirs, files in os.walk(folder, followlinks=False,
|
||||
onerror=lambda e: (_ for _ in ()).throw(e)):
|
||||
paths.extend(Path(base) / item for item in dirs + files)
|
||||
for path in paths:
|
||||
attributes = {}
|
||||
for key in os.listxattr(path, follow_symlinks=False):
|
||||
value = os.getxattr(path, key, follow_symlinks=False)
|
||||
attributes[key] = base64.b64encode(value).decode('ascii')
|
||||
count[key] += 1
|
||||
if attributes:
|
||||
stream.write(json.dumps({'path': str(path.relative_to(source)),
|
||||
'attributes_base64': attributes}, ensure_ascii=False) + '\n')
|
||||
entries += 1
|
||||
stream.flush()
|
||||
os.fsync(stream.fileno())
|
||||
os.chown(output, 1000, 1001)
|
||||
summary = {'entries': entries, 'attribute_names': dict(count), 'bytes': output.stat().st_size,
|
||||
'resource_fork_attributes': count['com.apple.ResourceFork']}
|
||||
(destination / 'README.txt').write_text(
|
||||
'这是 APFS 源目录的 macOS 扩展属性原始存档,不包含普通文件的数据内容。\n'
|
||||
'extended-attributes.jsonl 每行记录相对路径与 Base64 编码的原始属性。\n'
|
||||
'包含用户标签、Finder 信息和机器相关安全元数据,请随剪辑备份私下保管,不上传源码仓库。\n'
|
||||
'普通文件已由 rsync 复制;还原至 Mac 时应按需使用这些属性,不要盲目重放机器相关属性。\n')
|
||||
os.chown(destination / 'README.txt', 1000, 1001)
|
||||
print(json.dumps(summary, ensure_ascii=False))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
在新工单中引用
屏蔽一个用户