601451f22b
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>
39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
"""Consistent SQLite + asset backup. Run: docker compose exec siteforge python -m app.backup"""
|
|
import os
|
|
import sqlite3
|
|
import tempfile
|
|
import zipfile
|
|
from pathlib import Path
|
|
from datetime import datetime, timezone
|
|
from . import db
|
|
|
|
|
|
def backup():
|
|
# Never manufacture an empty SQLite file while the real application uses PostgreSQL.
|
|
if db.POSTGRES:
|
|
raise RuntimeError('PostgreSQL 模式不得使用 SQLite 备份;请使用 scripts/pg_disaster_recovery.py backup')
|
|
db.init()
|
|
storage=Path(db.DATA).resolve()
|
|
path=storage/'backups'
|
|
path.mkdir(exist_ok=True,parents=True)
|
|
name='siteforge-backup-'+datetime.now(timezone.utc).strftime('%Y%m%d-%H%M%S')+'.zip'
|
|
dest=path/name
|
|
# SQLite online backup is consistent even when the DB uses WAL mode.
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
snapshot=Path(tmp)/'siteforge.sqlite3'
|
|
with sqlite3.connect(db.DB_FILE) as source, sqlite3.connect(snapshot) as target:
|
|
source.backup(target)
|
|
with zipfile.ZipFile(dest,'w',compression=zipfile.ZIP_DEFLATED,compresslevel=5) as output:
|
|
output.write(snapshot,'siteforge.sqlite3')
|
|
for subdir in ('media','legacy','builds','archives'):
|
|
root=storage/subdir
|
|
if not root.is_dir():continue
|
|
for file in root.rglob('*'):
|
|
if file.is_file() and not file.is_symlink():
|
|
output.write(file, file.relative_to(storage).as_posix())
|
|
print(f'备份成功: {dest}')
|
|
print('注意:备份文件仍在 Docker 数据卷内。请使用 docker compose cp 或其他方式再复制到外部设备。')
|
|
return dest
|
|
|
|
if __name__=='__main__':backup()
|