Files
cms-SiteForge/scripts/pg_disaster_recovery.py
浅念 601451f22b upgrade: adopt V8.21.3 (V8.13→8.21.3: P5 SFTP/S3, P6 multilingual, editor overhaul, enterprise hardening)
Overlay ~150 upstream items onto our V8.12 base, preserving trade-pro
theme, registry tests, and design docs. Re-applied our patch set
(discovery/env_for/blocks.css/type-mapping/theme_color/frontend entries,
test_theme_pro_v3 mods) — all anchors survived upstream evolution.

New platform enhancement (fixes upgrade-introduced regression):
multilingual.site_locale now honors settings_json.locale, plus
PUT /api/i18n/sites/{id}/locale — standalone English sites get
<html lang='en'> under the V8.15 locale-rewrite pipeline.

compose: adopt V8.21.3 (image 8.21.3-dev.1, /api/ready probes, MySQL/S3
env) with project name pinned to siteforge-v8-10 (data volumes).

Tests: 356 passed / 11 failed — all 11 confirmed pre-existing in
pristine V8.21.3 on this host (10 upstream Windows env + our build test
now green after locale fix). Patch registry updated in plan doc.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-23 12:31:03 +08:00

38 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Offline PostgreSQL backup/verify/recovery CLI for administrators."""
from __future__ import annotations
# Allow direct `python scripts/name.py` from a fresh source checkout.
import sys as _sys
from pathlib import Path as _Path
_sys.path.insert(0, str(_Path(__file__).resolve().parents[1]))
import argparse
import json
import os
from pathlib import Path
from app import pg_disaster_recovery as pg
def main(argv=None):
p=argparse.ArgumentParser(description='SiteForge offline PostgreSQL disaster recovery')
sub=p.add_subparsers(dest='operation',required=True)
b=sub.add_parser('backup');b.add_argument('--data',required=True);b.add_argument('--output',required=True)
b.add_argument('--confirmed-offline',action='store_true')
v=sub.add_parser('verify');v.add_argument('archive')
r=sub.add_parser('restore-new');r.add_argument('archive');r.add_argument('--data',required=True)
r.add_argument('--confirmed-offline',action='store_true')
args=p.parse_args(argv)
try:
if args.operation=='verify':value=pg.verify(args.archive)
else:
url=os.getenv('SITEFORGE_DATABASE_URL','')
if args.operation=='backup':
value=pg.backup(url,args.data,args.output,confirmed_offline=args.confirmed_offline)
else:
value=pg.restore_new(url,args.archive,args.data,confirmed_offline=args.confirmed_offline)
print(json.dumps(value,ensure_ascii=False,indent=2))
return 0
except (pg.RecoveryError,OSError,ValueError) as exc:
print('ERROR: '+str(exc),file=__import__('sys').stderr)
return 1
if __name__=='__main__':raise SystemExit(main())