完成真实成对异机备份(07-26-internal-ops-recovery-baseline)
ci-e2e / e2e (push) Waiting to run
ci-minimal / check-minimal (push) Waiting to run

这个提交包含在:
2026-07-26 21:47:44 +08:00
父节点 7658051321
当前提交 9a624700d0
共修改 8 个文件,包含 133 行新增和 13 行删除
+45 -2
查看文件
@@ -67,8 +67,13 @@ STORAGE_BYTES="$(wc -c <"$STORAGE_FILE" | tr -d ' ')"
BUILD_SHA="$(git -C "$ROOT_DIR" rev-parse --short=12 HEAD 2>/dev/null || true)"
CREATED_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
node - "$TEMP_DIR/$MANIFEST_NAME" "$BACKUP_RUN_ID" "$CREATED_AT" "$BUILD_SHA" \
"$DB_NAME" "$DB_BYTES" "$DB_SHA256" "$STORAGE_NAME" "$STORAGE_BYTES" "$STORAGE_SHA256" <<'NODE'
MANIFEST_ARGS=(
"$TEMP_DIR/$MANIFEST_NAME" "$BACKUP_RUN_ID" "$CREATED_AT" "$BUILD_SHA"
"$DB_NAME" "$DB_BYTES" "$DB_SHA256" "$STORAGE_NAME" "$STORAGE_BYTES" "$STORAGE_SHA256"
)
if command -v node >/dev/null 2>&1; then
node - "${MANIFEST_ARGS[@]}" <<'NODE'
const fs = require("node:fs");
const [manifestPath, runId, createdAt, buildSha, dbFile, dbBytes, dbSha256, storageFile, storageBytes, storageSha256] = process.argv.slice(2);
const manifest = {
@@ -84,6 +89,44 @@ const manifest = {
};
fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, { encoding: "utf8", flag: "wx" });
NODE
elif command -v python3 >/dev/null 2>&1; then
python3 - "${MANIFEST_ARGS[@]}" <<'PYTHON'
import json
import sys
(
manifest_path,
run_id,
created_at,
build_sha,
db_file,
db_bytes,
db_sha256,
storage_file,
storage_bytes,
storage_sha256,
) = sys.argv[1:]
manifest = {
"schemaVersion": 1,
"runId": run_id,
"createdAt": created_at,
"buildSha": build_sha or None,
"status": "complete",
"artifacts": {
"database": {"file": db_file, "bytes": int(db_bytes), "sha256": db_sha256},
"storage": {"file": storage_file, "bytes": int(storage_bytes), "sha256": storage_sha256},
},
}
with open(manifest_path, "x", encoding="utf-8") as manifest_file:
json.dump(manifest, manifest_file, ensure_ascii=True, indent=2)
manifest_file.write("\n")
PYTHON
else
echo "[ERR] node or python3 is required to write the backup manifest" >&2
exit 1
fi
mv "$TEMP_DIR" "$FINAL_DIR"
TEMP_DIR=""