Skip to content

Export rules and logs, and re-import rules #49

Description

@CharanMN7

What to build

Export rules and send history from the admin panel — JSON for rules, CSV for logs — and re-import rules.

Why

Three reasons, in order of how often they will actually come up:

  1. Moving deployments. Someone rebuilds on a new Cloudflare account and does not want to retype forty rules.
  2. Backup. D1 has no automatic backup on the free tier. A rule set that took an afternoon to write lives in exactly one place.
  3. It is their data. A self-hosted tool that traps your data is missing the point.

Notes

  • Export rules as JSON, logs as CSV. Rules are structured and get re-imported; logs go into a spreadsheet.
  • Never export tokens, encrypted or otherwise, and never export access_token_enc or token_iv. Exclude them explicitly rather than relying on a SELECT happening not to include them.
  • Log exports contain commenter ids. Say so on the export screen — that is someone's audience data leaving the system.
  • Import must validate exactly as the rule form does, preview before writing, and never partially apply a bad file.
  • Large exports on a Worker need streaming or a row cap. Decide which and document the limit.

Acceptance criteria

  • Rules export as JSON, excluding every token field
  • Logs export as CSV with a documented row cap or streaming
  • Rule import validates and previews before writing
  • Import is all-or-nothing
  • Export screen states what personal data is included
  • Round-trip test: export, wipe, import, rules are identical

Where to look

  • src/routes/admin.ts, src/db.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: opsDeployment, migrations, monitoring, DXeffort: mediumA few sessions. Touches several files.enhancementNew feature or requestroadmapA planned feature from the README roadmap

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions