Storage Operations Runbook¶
Operational runbook for analysis persistence backends used in https://github.com/ringxworld/story_generator/issues/11.
Backend Modes¶
Configured via environment variables:
STORY_GEN_ANALYSIS_BACKEND=sqlite(default)STORY_GEN_ANALYSIS_BACKEND=mongo-prototypewithSTORY_GEN_ENABLE_MONGO_ADAPTER=1STORY_GEN_ANALYSIS_BACKEND=graph-prototypewithSTORY_GEN_ENABLE_GRAPH_ADAPTER=1
Default data roots (derived from STORY_GEN_DB_PATH):
- SQLite:
<db_path> - Mongo prototype:
<db_stem>.mongo_analysis_runs.jsonl - Graph prototype:
<db_stem>.graph_analysis_runs.jsonl
Backup Procedures¶
SQLite:
- Stop writers (API worker drain or maintenance window).
- Copy DB file to timestamped backup:
cp work/local/story_gen.db backups/story_gen-YYYYMMDDHHMM.db - Restart writers.
Mongo/graph prototype JSONL:
- Stop writers.
- Copy
*.jsonland*.meta.jsonfiles to timestamped backup path. - Restart writers.
Restore Procedures¶
SQLite:
- Stop API/CLI writers.
- Replace target DB file with selected backup.
- Start API and run smoke checks:
GET /healthz- authenticated
GET /api/v1/stories/{story_id}/analysis/latest
Mongo/graph prototype:
- Stop API/CLI writers.
- Replace affected
*.jsonland*.meta.jsonfiles from backup. - Start API and run the same smoke checks.
Retention Policy¶
- Local/dev minimum:
- keep daily backups for 14 days
- keep weekly backups for 8 weeks
- Shared staging:
- keep daily backups for 30 days
- keep monthly backups for 6 months
- Prune older snapshots only after confirming a successful newer backup.
Rollback Policy¶
Rollback from prototype backends to SQLite:
- Set
STORY_GEN_ANALYSIS_BACKEND=sqlite. - Remove prototype enable flags.
- Restart API workers.
- Run:
uv run python tools/check_contract_drift.pyuv run pytest tests/test_api_app.py
Validation Checklist¶
After any backend switch, backup restore, or rollback:
uv run python tools/check_contract_drift.pyuv run pytest tests/test_story_analysis_store_factory.pyuv run pytest tests/test_api_app.pyuv run mkdocs build --strict