Files
bionickatana d535c57347
CI / scan_ruby (pull_request) Failing after 11s
CI / scan_js (pull_request) Failing after 7s
CI / lint (pull_request) Failing after 10s
added backup/restore feature
2026-09-28 09:46:35 -06:00

2.1 KiB

Phase 008: Backup And Restore

Goal

Add backup and restore support for portable application data using compressed YAML files without adding new gem dependencies.

Work

  • Add a backup/restore page linked from the main vehicle dashboard.
  • Export app data as a versioned YAML document compressed with gzip (.yml.gz).
  • Include users, vehicles, maintenance schedules, fuel entries, and maintenance entries.
  • Exclude authentication and runtime data, including access keys and user sessions.
  • Restore uploaded backups in either merge mode or replace mode.
  • Use portable references instead of raw database IDs so backups can be moved between installations.
  • Support older backup versions only when an explicit migration path exists.
  • Add request specs for export, merge restore, replace restore, invalid upload handling, and authentication.

Decisions

  • Backups use gzip-compressed YAML instead of zip archives because no extra gem dependency should be added.
  • Any identified user may export or restore backups.
  • Merge mode updates matched users, vehicles, and maintenance schedules, and creates unmatched records.
  • Users are matched by normalized email.
  • Vehicles are matched by VIN.
  • Maintenance schedules are matched by vehicle and maintenance type.
  • Fuel and maintenance entries use natural keys to avoid duplicate imports.
  • Replace mode removes existing app data and imports the uploaded data inside one transaction.
  • Restore recalculates vehicle odometers from imported/stored vehicle odometers and event histories.

Deliverables

  • Backup export/import services.
  • Backup controller and routes.
  • Backup/restore page and dashboard link.
  • Request specs for backup and restore behavior.
  • Phase execution notes.

Acceptance Criteria

  • Authenticated users can download a .yml.gz backup from the app.
  • The backup contains app data only and excludes auth/session data.
  • Authenticated users can restore by replacing all app data.
  • Authenticated users can restore by merging portable records into existing app data.
  • Invalid or unsupported uploads fail with a clear user-facing error.
  • Backup and restore behavior is covered by request specs.